﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.IO;
using System.Text;

using CE.User;
using CE.Global;
using CE.Provider;
using CE.CarInsurance;
using CE.Database;

public partial class Provider_ProposalForm_ProposalForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        if (!IsPostBack)
        {
            string[] vals = Request.QueryString["Ref"].ToString().Split(',');
            string pdf = "";
            string val = "";
            if(vals.Length == 2)
            {
                pdf = vals[1].ToString();
                val = vals[0].ToString();
            }
            else
            {
                pdf = "";
                val = Request.QueryString["Ref"].ToString();
            }
            //val = CE.Security.MySecurity.Decrypt(val.ToString().Trim(), true);
           
            Int64 RefId = Convert.ToInt64(val);
            string InsType = Session[General.InsType].ToString();
            string convertno = General.GetRefNumber(RefId);
            string _fileName = "FileName";
            string _downloaddate = " : " + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Year + " " + CE.Global.General.GetUTCDateTime().ToShortTimeString();  //+CE.Global.General.GetUTCDateTime().Hour.ToString("00") + ":" + CE.Global.General.GetUTCDateTime().Minute.ToString("00") + " " + CE.Global.General.GetUTCDateTime().Ticks;
            if (Session[CE.Global.General.ProviderCompanyId].ToString() == "23")
            {
                if (Session[General.InsType].ToString() == "CI")
                {
                    if (pdf == "pdf")
                    {
                        GetCIPDF_Hsbc(RefId, InsType);
                    }
                    else
                    {
                        //divContent.InnerHtml = GenerateCIHTML(RefId, InsType);
                        lblContent.Text = GenerateCIHTML_Hsbc(RefId, InsType);
                        _fileName = "H" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                        StringBuilder strText = new StringBuilder("");
                        //strText.Append("<table><tr><td><h3>Car Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>DownLoad Date" + _downloaddate.ToString() + "    </td></tr></table>");
                        strText.Append("<table><tr><td colspan='2'><h3>Car Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                        strText.Append("<tr><td><b>Insurer</b></td><td>HSBC Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                        ExportGridView(_fileName, lblContent, strText.ToString());
                    }
                }
                else if (Session[General.InsType].ToString() == "TI")
                {
                    lblContent.Text = GenerateTIHTML_Hsbc(RefId, InsType);
                    _fileName = "TIH" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    //strText.Append("<table><tr><td><h3>Travel Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>Download Date" + _downloaddate.ToString() + "    </td></tr></table>");
                    strText.Append("<table><tr><td colspan='2'><h3>Travel Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>HSBC Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
                else if (Session[General.InsType].ToString() == "PA")
                {
                    lblContent.Text = GeneratePAHTML_Hsbc(RefId, InsType);
                    _fileName = "PAH" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    //strText.Append("<table><tr><td><h3>Personal Accident - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>Download Date" + _downloaddate.ToString() + "    </td></tr></table>");
                    strText.Append("<table><tr><td colspan='2'><h3>Personal Accident - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>HSBC Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
            }
            if (Session[CE.Global.General.ProviderCompanyId].ToString() == "29")
            {
                if (Session[General.InsType].ToString() == "CI")
                {
                    lblContent.Text = GenerateCIHTML_Liberty(RefId, InsType);
                    _fileName = "L" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    //strText.Append("<table><tr><td><h3>Car Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>DownLoad Date" + _downloaddate.ToString() + "</td></tr></table>");
                    strText.Append("<table><tr><td colspan='2'><h3>Car Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>Liberty Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
                else if (Session[General.InsType].ToString() == "TI")
                {
                    lblContent.Text = GenerateTIHTML_Liberty(RefId, InsType);
                    _fileName = "TIL" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    //strText.Append("<table><tr><td><h3>Travel Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>Download Date" + _downloaddate.ToString() + "</td></tr></table>");
                    strText.Append("<table><tr><td colspan='2'><h3>Travel Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>Liberty Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
                else if (Session[General.InsType].ToString() == "PA")
                {
                    lblContent.Text = GeneratePAHTML_Liberty(RefId, InsType);
                    _fileName = "PAL" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    strText.Append("<table><tr><td colspan='2'><h3>Personal Accident - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>Liberty Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
            }
            if (Session[CE.Global.General.ProviderCompanyId].ToString() == "30")
            {
                if (Session[General.InsType].ToString() == "CI")
                {
                    lblContent.Text = GenerateCIHTML_Etiqa(RefId, InsType);
                    _fileName = "E" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    //strText.Append("<table><tr><td><h3>Car Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>DownLoad Date" + _downloaddate.ToString() + "</td></tr></table>");
                    strText.Append("<table><tr><td colspan='2'><h3>Car Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>Etiqa Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
                else if (Session[General.InsType].ToString() == "PA")
                {
                    lblContent.Text = GeneratePAHTML_Etiqa(RefId, InsType);
                    _fileName = "PAE" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
                    StringBuilder strText = new StringBuilder("");
                    strText.Append("<table><tr><td colspan='2'><h3>Personal Accident - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
                    strText.Append("<tr><td><b>Insurer</b></td><td>Etiqa Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
                    ExportGridView(_fileName, lblContent, strText.ToString());
                }
            }
            //if (Session[CE.Global.General.ProviderCompanyId].ToString() == "24")
            //{
            //    if (Session[General.InsType].ToString() == "CI")
            //    {
            //        lblContent.Text = GenerateCIHTML_Rsa(RefId, InsType);
            //        _fileName = "R" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
            //        StringBuilder strText = new StringBuilder("");
            //        //strText.Append("<table><tr><td><h3>Car Insurance - Proposal Form</h3></td><td>" + _fileName + "</td><td colspan='2' align='right'>DownLoad Date" + _downloaddate.ToString() + "</td></tr></table>");
            //        strText.Append("<table><tr><td colspan='2'><h3>Car Insurance - Proposal Form</h3></td><td colspan='2' align='right'><b>File Name</b> : " + _fileName.ToString() + "</td></tr>");
            //        strText.Append("<tr><td><b>Insurer</b></td><td>RSA Insurance</td><td colspan='2' align='right'><b>Download Date</b> " + _downloaddate.ToString() + "</td></tr></table>");
            //        ExportGridView(_fileName, lblContent, strText.ToString());
            //    }
            //}
        }
    }

    public string GenerateCIHTML_Hsbc(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetHSBCProposalPDF(RefId, InsuranceType);
        string _html = "";
        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            #region variables
            string _name, _dob, _nationality, _nric, _drvlicenceobtained, _maritalstatus, _mobile, _hoemphone, _officephone, _faxno, _unitno, _homeno, _address;
            string _postalcode, _gender, _empname, _email, _addidentdate, _natureofaccident, _claimamount, _typeofclaim, _revokedstatus;
            string _revokedyear, _revokedreason, _claimstatus, _dd, _mm, _yy, _occupation, _jobnature, _claim1ststat, _claim1stend, claimamt1;
            string _claimcount1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _inscomp;
            string _ncdreson, _vehicleno, _makemodel, _cc, _enginetype, _regyear, _offpeakcar, _bodytype, _purchaseprice, _engineno, _chassisno;
            string _insstartdate, _insenddate, _hp, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _drname1, _drdob1, _drdd1, _drmm1, _dryy1, _drocc1, _drnobus1;
            string _drname2, _drdob2, _drdd2, _drmm2, _dryy2, _drocc2, _drnobus2, _drname3, _drdob3, _drdd3, _drmm3, _dryy3, _drocc3, _drnobus3;
            string _drname4, _drdob4, _drdd4, _drmm4, _dryy4, _drocc4, _drnobus4, _drname5, _drdob5, _drdd5, _drmm5, _dryy5, _drocc5, _drnobus5;
            string _adddriver, _drcount, _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _installmentype, _installmentmonth, _planname, _covertype, _annualpremium;
            string _vehiclemodifystatus, _vehiclemodifyreason, _withoutcoeparf, _excess, _purposeofuse, _renewalncdpercent;

            string _dryearofobtained1, _drrelation1, _drrevokedstatus1, _drrevokedyear1, _drrevokedreason1, _drclaimstatus1;
            string _draccidentdate1, _drnatureofacc1, _drclaimamount1, _drtypeofclaim1;

            string _dryearofobtained2, _drrelation2, _drrevokedstatus2, _drrevokedyear2, _drrevokedreason2, _drclaimstatus2;
            string _draccidentdate2, _drnatureofacc2, _drclaimamount2, _drtypeofclaim2;
            string _ncdprotection, _purpose;
            DateTime _dofb, _isdate, _iedate, _drdofb1, _drdofb2, _drdofb3, _drdofb4, _drdofb5, _hpcomname;
            _drname1 = "N/A"; _drdob1 = "N/A"; _drdd1 = ""; _drmm1 = ""; _dryy1 = ""; _drocc1 = ""; _drnobus1 = "";
            _drname2 = "N/A"; _drdob2 = "N/A"; _drdd2 = ""; _drmm2 = ""; _dryy2 = ""; _drocc2 = ""; _drnobus2 = "";
            _drname3 = ""; _drdob3 = "01/01/1900"; _drdd3 = ""; _drmm3 = ""; _dryy3 = ""; _drocc3 = ""; _drnobus3 = "";
            _drname4 = ""; _drdob4 = "01/01/1900"; _drdd4 = ""; _drmm4 = ""; _dryy4 = ""; _drocc4 = ""; _drnobus4 = "";
            _drname5 = ""; _drdob5 = "01/01/1900"; _drdd5 = ""; _drmm5 = ""; _dryy5 = ""; _drocc5 = ""; _drnobus5 = ""; _planname = ""; _annualpremium = "";
            _adddriver = ""; _drcount = ""; _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = ""; _installmentype = ""; _installmentmonth = "";

            _ncdprotection = "No";
            _purpose = "";

            _revokedstatus = "No"; _revokedyear = "N/A"; _revokedreason = "N/A";
            _addidentdate = "N/A"; _natureofaccident = "N/A"; _claimamount = "N/A"; _typeofclaim = "N/A";

            _dryearofobtained1 = "N/A"; _drrelation1 = "N/A"; _drrevokedstatus1 = "No"; _drrevokedyear1 = "N/A"; _drrevokedreason1 = "N/A";
            _drclaimstatus1 = "No"; _draccidentdate1 = "N/A"; _drnatureofacc1 = "N/A"; _drclaimamount1 = "N/A"; _drtypeofclaim1 = "N/A";

            _dryearofobtained2 = "N/A"; _drrelation2 = "N/A"; _drrevokedstatus2 = "No"; _drrevokedyear2 = "N/A"; _drrevokedreason2 = "N/A";
            _drclaimstatus2 = "No"; _draccidentdate2 = "N/A"; _drnatureofacc2 = "N/A"; _drclaimamount2 = "N/A"; _drtypeofclaim2 = "N/A";

            _name = _dsProposal.Tables[0].Rows[0]["FamilyName"].ToString() + " " + _dsProposal.Tables[0].Rows[0]["GivenName"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString().Substring(2, 2);
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _drvlicenceobtained = _dsProposal.Tables[0].Rows[0]["YearofObtained"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            //_email = CE.Security.MySecurity.Decrypt(_dsProposal.Tables[0].Rows[0]["Email"].ToString(), true);
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _jobnature = _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString();
            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _faxno = _dsProposal.Tables[0].Rows[0]["FaxNo"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpName"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _covertype = _dsProposal.Tables[0].Rows[0]["ProviderCoverTypeDesc"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["Info4"].ToString() == "True")
            {
                _ncdprotection = "Yes";
            }

            _purpose = _dsProposal.Tables[0].Rows[0]["OtherReason"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
            }

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";

                _ncdpercent = "0%";
            }

            if (_dsProposal.Tables[2].Rows.Count > 0)
            {
                _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
                
                string _isncdprotect = "";
                _isncdprotect = _dsProposal.Tables[0].Rows[0]["Info4"].ToString(); ;


                if (_isncdprotect.ToString() == "False")
                {
                    _ncdstatus = "Not Applicable";
                }
                else
                {
                    _ncdstatus = "Yes";
                }
            }
            else
            {
                _ncdstatus = "No";
                _inscomp = "Not Applicable";
            }

            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            if (_ncdreson.ToString() == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson.ToString() == "-1")
            {
                _ncdreson = "Not Applicable";
            }

            _renewalncdpercent = _dsProposal.Tables[0].Rows[0]["RenewalNCDPercent"].ToString() + "%";
            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "10%";
            }
            else
            {
                if (_claimstatus == "No")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "0")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "1")
                {
                    _ncdpercent = OneTimesNCD(_ncdpercent);
                }
                else
                {
                    _ncdpercent = "0%";
                }
            }
            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["RegYear"].ToString();
            _makemodel = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _offpeakcar = _dsProposal.Tables[0].Rows[0]["Offbeak"].ToString();
            if (Convert.ToBoolean(_dsProposal.Tables[0].Rows[0]["IsInsCOE"].ToString()) == false)
            {
                _withoutcoeparf = "Yes";
            }
            else
            {
                _withoutcoeparf = "No";
            }
            _excess = _dsProposal.Tables[0].Rows[0]["Excess"].ToString();
            _vehiclemodifystatus = _dsProposal.Tables[0].Rows[0]["VehclModify"].ToString();
            _vehiclemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["PurposeofUse"].ToString() == "1")
            {
                _purposeofuse = "Social Use";
            }
            else
            {
                _purposeofuse = "Others";
            }

            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _enginetype = _dsProposal.Tables[0].Rows[0]["EngineType"].ToString();
            _bodytype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _purchaseprice = _dsProposal.Tables[0].Rows[0]["PurchasePrice"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString().Substring(2, 2);
            _insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            //_insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString().Substring(2, 2);
            _insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            //_insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();
            if (Convert.ToBoolean(_dsProposal.Tables[0].Rows[0]["HasLicenceRevoked"].ToString()) == true)
            {
                _revokedstatus = "Yes";
                _revokedyear = _dsProposal.Tables[0].Rows[0]["YearofRevoked"].ToString();
                _revokedreason = _dsProposal.Tables[0].Rows[0]["RevokedReason"].ToString();
            }
            if (_dsProposal.Tables[6].Rows.Count > 0)
            {
                _addidentdate = _dsProposal.Tables[6].Rows[0]["AccidentDate"].ToString();
                _natureofaccident = _dsProposal.Tables[6].Rows[0]["NatureofAccident"].ToString();
                _claimamount = _dsProposal.Tables[6].Rows[0]["ClaimAmount"].ToString();
                _typeofclaim = _dsProposal.Tables[6].Rows[0]["TypeofClaim"].ToString();
            }

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hp.ToString() == "")
                {
                    _hp = "Not Applicable";
                }
            }
            else
            {
                _hp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drdofb1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["DOB"].ToString());
                    _drdd1 = _drdofb1.Day.ToString("00");
                    _drmm1 = _drdofb1.Month.ToString("00");
                    _dryy1 = _drdofb1.Year.ToString().Substring(2, 2);
                    //_drdob1 = _drdd1 + "/" + _drmm1 + "/" + _dryy1;
                    _drdob1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drnobus1 = _dsProposal.Tables[4].Rows[0]["DvrBusiness"].ToString();

                    _dryearofobtained1 = _dsProposal.Tables[4].Rows[0]["YearofObtained"].ToString();
                    _drrelation1 = _dsProposal.Tables[4].Rows[0]["RelationShip"].ToString();
                    if (_dsProposal.Tables[4].Rows[0]["RevokedStatus"].ToString() == "True")
                    {
                        _drrevokedstatus1 = "Yes";
                        _drrevokedyear1 = _dsProposal.Tables[4].Rows[0]["RevokedYear"].ToString();
                        _drrevokedreason1 = _dsProposal.Tables[4].Rows[0]["RevokedReason"].ToString();
                    }
                    if (_dsProposal.Tables[4].Rows[0]["ClaimStatus"].ToString() == "True")
                    {
                        _drclaimstatus1 = "Yes";
                        //DateTime _accdate1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString());
                        //_draccidentdate1 = _accdate1.Day.ToString("00") + "/" + _accdate1.Month.ToString("00") + "/" + _accdate1.Year.ToString("0000");
                        _draccidentdate1 = _dsProposal.Tables[4].Rows[0]["AccidentDate"].ToString();
                        _drnatureofacc1 = _dsProposal.Tables[4].Rows[0]["NatureofAccident"].ToString();
                        _drclaimamount1 = _dsProposal.Tables[4].Rows[0]["ClaimAmount"].ToString();
                        _drtypeofclaim1 = _dsProposal.Tables[4].Rows[0]["TypeofClaim"].ToString();
                    }
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drdofb2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["DOB"].ToString());
                    _drdd2 = _drdofb2.Day.ToString("00");
                    _drmm2 = _drdofb2.Month.ToString("00");
                    _dryy2 = _drdofb2.Year.ToString().Substring(2, 2);
                    //_drdob2 = _drdd2 + "/" + _drmm2 + "/" + _dryy2;
                    _drdob2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drnobus2 = _dsProposal.Tables[4].Rows[1]["DvrBusiness"].ToString();

                    _dryearofobtained2 = _dsProposal.Tables[4].Rows[1]["YearofObtained"].ToString();
                    _drrelation2 = _dsProposal.Tables[4].Rows[1]["RelationShip"].ToString();
                    if (_dsProposal.Tables[4].Rows[1]["RevokedStatus"].ToString() == "True")
                    {
                        _drrevokedstatus2 = "Yes";
                        _drrevokedyear2 = _dsProposal.Tables[4].Rows[1]["RevokedYear"].ToString();
                        _drrevokedreason2 = _dsProposal.Tables[4].Rows[1]["RevokedReason"].ToString();
                    }
                    if (_dsProposal.Tables[4].Rows[1]["ClaimStatus"].ToString() == "True")
                    {
                        _drclaimstatus2 = "Yes";
                        //DateTime _accdate2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString());
                        //_draccidentdate2 = _accdate2.Day.ToString("00") + "/" + _accdate2.Month.ToString("00") + "/" + _accdate2.Year.ToString("0000");
                        _draccidentdate2 = _dsProposal.Tables[4].Rows[1]["AccidentDate"].ToString();
                        _drnatureofacc2 = _dsProposal.Tables[4].Rows[1]["NatureofAccident"].ToString();
                        _drclaimamount2 = _dsProposal.Tables[4].Rows[1]["ClaimAmount"].ToString();
                        _drtypeofclaim2 = _dsProposal.Tables[4].Rows[1]["TypeofClaim"].ToString();
                    }
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drdofb3 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[2]["DOB"].ToString());
                    _drdd3 = _drdofb3.Day.ToString("00");
                    _drmm3 = _drdofb3.Month.ToString("00");
                    _dryy3 = _drdofb3.Year.ToString().Substring(2, 2);
                    //_drdob3 = _drdd3 + "/" + _drmm3 + "/" + _dryy3;
                    _drdob3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drnobus3 = _dsProposal.Tables[4].Rows[2]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drdofb4 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[3]["DOB"].ToString());
                    _drdd4 = _drdofb4.Day.ToString("00");
                    _drmm4 = _drdofb4.Month.ToString("00");
                    _dryy4 = _drdofb4.Year.ToString().Substring(2, 2);
                    //_drdob4 = _drdd4 + "/" + _drmm4 + "/" + _dryy4;
                    _drdob4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drnobus4 = _dsProposal.Tables[4].Rows[3]["DvrBusiness"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drdofb5 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[4]["DOB"].ToString());
                    _drdd5 = _drdofb5.Day.ToString("00");
                    _drmm5 = _drdofb5.Month.ToString("00");
                    _dryy5 = _drdofb5.Year.ToString().Substring(2, 2);
                    //_drdob5 = _drdd5 + "/" + _drmm5 + "/" + _dryy5;
                    _drdob5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drnobus5 = _dsProposal.Tables[4].Rows[4]["DvrBusiness"].ToString();
                }
            }


            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 23, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                _installmentype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();
                if (_dsPayment.Tables[0].Rows[0]["InstallmentMonth"] != null && _dsPayment.Tables[0].Rows[0]["InstallmentMonth"].ToString() != "")
                {
                    Int32 _month = Convert.ToInt32(_dsPayment.Tables[0].Rows[0]["InstallmentMonth"].ToString());
                    if (_month == 0)
                    {
                        _installmentmonth = "";
                    }
                    else
                    {
                        _installmentmonth = _dsPayment.Tables[0].Rows[0]["InstallmentMonth"].ToString() + " Month Installment";
                    }
                }
                else
                {
                    _installmentmonth = "";
                }

                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }
            #endregion

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr></table>";
            _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Occupation / Nature of Business</td>"
                     + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Mobile No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Residential No</td>"
                     + "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name of employer</td>"
                     + "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date driving licence obtained</td>"
                     + "<td width='50%' align='left'>" + _drvlicenceobtained + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>NRIC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Gender</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Marital Status</td>"
                     + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Office No</td>"
                     + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Fax No</td>"
                     + "<td width='50%' align='left'>" + _faxno.ToString() + "</td>"
                     + "</tr>"

                     //+ "<tr>"
                //+ "<td width='50%' align='left'>Residential No</td>"
                //+ "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                //+ "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Email Address</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"


                     + "<tr>"
                     + "<td width='50%' align='left' ></td>"
                     + "<td width='50%' align='left'></td>"
                     + "</tr>"


                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2' align='left'> At fault motor claims experiences, please provide the reason : " + _claimstatus.ToString() + "</td>"
                     + "</tr>";
            if (_claimstatus == "Yes")
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr><td style='width:25%' align='left'>Accident Date</td>"
                + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _addidentdate.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Claim Amount</td>"
                + "<td style='width: 25%' align='left'>" + _claimamount.ToString() + "</td></tr>"

                +"<tr><td style='width:25%' align='left'>Nature of Accident</td>"
                + "<td style='width:25%' align='left'> " + _natureofaccident.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Type of Claim</td>"
                + "<td style='width: 25%' align='left'>" + _typeofclaim.ToString() + "</td></tr>"
                                
                + "</table>"
                + "</td>"
                + "</tr>";
            }
            //if (claimamt1.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
            //}
            //if (claimamt2.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
            //}
            //if (claimamt3.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
            //}

            _html += "<tr>"
            + "<td colspan='2' align='left'> Record of revoked/endorsed driving licence (please provide details below) : " + _revokedstatus.ToString() + "</td>"
            + "</tr>";
            if (_revokedstatus == "Yes")
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr><td style='width:25%' align='left'>Year</td>"
                + "<td style='width:25%' align='left'> " + _revokedyear.ToString() + "</td>"
                + "<td style='width: 25%' align='left'> Reason</td>"
                + "<td style='width: 25%' align='left'>" + _revokedreason.ToString() + "</td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>";
            }

             _html += "<tr>"
             + "<td colspan='2' align='left'>No Claim Discount(NCD) to be transferred to this insurance policy : " + _ncdstatus.ToString() + "</td>"
             + "</tr>"

             + "<tr>"
             + "<td colspan='2'>"
             + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

             + "<tr><td style='width:25%' align='left'>NCD on next renewal (%)</td>"
             //+ "<td style='width: 25%' align='left'>" + _ncdpercent.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>" + _renewalncdpercent.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Insurance Company</td>"
             + "<td style='width: 25%' align='left'>" + _inscomp.ToString() + "</td></tr>"

             + "<tr>"
             + "<td colspan='4' align='left'>NCD Protection : " + _ncdprotection.ToString() + "</td>"
             + "</tr>"

             + "<tr>"
             + "<td colspan='4' align='left'>If NCD is nil or 10% with no claims experiences, please provide reason : " + _ncdreson.ToString() + "</td>"
             + "</tr>"

              + "<tr>"
             + "<td colspan='4' align='left'>State the purpose : " + _purpose.ToString() + "</td>"
             + "</tr>"

             + "<tr><td colspan='4' align='left'><b>Details of motor car to be insured</b></td></tr>"

             + "<tr><td style='width:25%' align='left'>Registration No</td>"
             + "<td style='width: 25%' align='left'>" + _vehicleno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Year of Registration</td>"
             + "<td style='width: 25%' align='left'>" + _regyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Make and Model</td>"
             + "<td style='width: 25%' align='left'>" + _makemodel.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Off peak car?</td>"
             + "<td style='width: 25%' align='left'>" + _offpeakcar.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Cubic capacity (CC)</td>"
             + "<td style='width: 25%' align='left'>" + _cc.ToString() + "cc</td>"
             + "<td style='width: 25%' align='left'>Engine Type</td>"
             + "<td style='width: 25%' align='left'>" + _enginetype.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Type of Body</td>"
             + "<td style='width: 25%' align='left'>" + _bodytype.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Purchase price</td>"
             + "<td style='width: 25%' align='left'>" + _purchaseprice.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Engine Number</td>"
             + "<td style='width: 25%' align='left'>" + _engineno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Chassis Number</td>"
             + "<td style='width: 25%' align='left'>" + _chassisno.ToString() + "</td></tr>"

             + "<tr>"
             + "<td colspan='2' align='left'>Name of hire purchase owner(s), if any</td>"
             + "<td colspan='2' align='left'>" + _hp.ToString() + "</td>"
             + "</tr>"

             + "<tr><td colspan='4' align='left'><b>Details of insurance required</b></td></tr>"

             + "<tr><td colspan='4' align='left'>Period of insurance required</td></tr>"

             + "<tr><td style='width:25%' align='left'>From</td>"
             + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>To midnight of</td>"
             + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td></tr>"

             + "<tr><td colspan='4' align='left'><b>Details of main driver / named driver : </b>" + _adddriver.ToString() + "</td></tr>";
            if (Convert.ToInt16(_drcount) > 0)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 1</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Date driving licence obtained</td>"
                + "<td style='width: 25%' align='left'>" + _dryearofobtained1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Relationship to Proposer</td>"
                + "<td style='width: 25%' align='left'>" + _drrelation1.ToString() + "</td></tr>"

                + "<tr>"
                + "<td colspan='4' align='left'> Record of revoked/endorsed driving licence (please provide details below) : " + _drrevokedstatus1.ToString() + "</td>"
                + "</tr>";
                if (_drrevokedstatus1 == "Yes")
                {
                    _html += "<tr><td style='width:25%' align='left'>Year</td>"
                    + "<td style='width:25%' align='left'> " + _drrevokedyear1.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Reason</td>"
                    + "<td style='width: 25%' align='left'>" + _drrevokedreason1.ToString() + "</td></tr>";
                }

                _html += "<tr>"
                + "<td colspan='4' align='left'> At fault motor claims experiences in past 3 years(please provide details below) : " + _drclaimstatus1.ToString() + "</td>"
                + "</tr>";
                if (_drclaimstatus1 == "Yes")
                {

                    _html += "<tr><td style='width:25%' align='left'>Accident Date</td>"
                    + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _draccidentdate1.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Claim Amount</td>"
                    + "<td style='width: 25%' align='left'>" + _drclaimamount1.ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Nature of Accident</td>"
                    + "<td style='width:25%' align='left'> " + _drnatureofacc1.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Type of Claim</td>"
                    + "<td style='width: 25%' align='left'>" + _drtypeofclaim1.ToString() + "</td></tr>";
                }
            }
            if (Convert.ToInt16(_drcount) > 1)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 2</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus2.ToString() + "</td></tr>"
                
                + "<tr><td style='width:25%' align='left'>Date driving licence obtained</td>"
                + "<td style='width: 25%' align='left'>" + _dryearofobtained2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Relationship to Proposer</td>"
                + "<td style='width: 25%' align='left'>" + _drrelation2.ToString() + "</td></tr>"
                
                +"<tr>"
                + "<td colspan='4' align='left'> Record of revoked/endorsed driving licence (please provide details below) : " + _drrevokedstatus2.ToString() + "</td>"
                + "</tr>";
                if (_drrevokedstatus2 == "Yes")
                {
                    _html += "<tr><td style='width:25%' align='left'>Year</td>"
                    + "<td style='width:25%' align='left'> " + _drrevokedyear2.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Reason</td>"
                    + "<td style='width: 25%' align='left'>" + _drrevokedreason2.ToString() + "</td></tr>";
                }

                _html += "<tr>"
                + "<td colspan='4' align='left'> At fault motor claims experiences in past 3 years(please provide details below) : " + _drclaimstatus2.ToString() + "</td>"
                + "</tr>";
                if (_drclaimstatus2 == "Yes")
                {

                    _html += "<tr><td style='width:25%' align='left'>Accident Date</td>"
                    + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _draccidentdate2.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Claim Amount</td>"
                    + "<td style='width: 25%' align='left'>" + _drclaimamount2.ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Nature of Accident</td>"
                    + "<td style='width:25%' align='left'> " + _drnatureofacc2.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Type of Claim</td>"
                    + "<td style='width: 25%' align='left'>" + _drtypeofclaim2.ToString() + "</td></tr>";
                }
            }
            if (Convert.ToInt16(_drcount) > 2)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 3</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus3.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 3)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 4</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus4.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 4)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 5</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date of Birth</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Nature of Business</td>"
                + "<td style='width: 25%' align='left'>" + _drnobus5.ToString() + "</td></tr>";
            }

            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetCarDownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Details</b></td></tr>"

                + "<tr><td style='width:25%' align='left'>Payment Mode</td>"
                + "<td style='width: 25%' align='left'>Credit Card</td>";
                if (_installmentype == "Monthly")
                {
                    _html += "<td style='width: 25%' align='left'></td>"
                    + "<td style='width: 25%' align='left'></td></tr>"

                    + "<tr><td style='width:25%' align='left'>Installment Type</td>"
                    + "<td style='width: 25%' align='left'>" + _installmentype.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Installment Month</td>"
                    + "<td style='width: 25%' align='left'>" + _installmentmonth.ToString() + "</td></tr>";
                }
                else
                {
                    _html += "<td style='width: 25%' align='left'>Installment Type</td>"
                    + "<td style='width: 25%' align='left'>" + _installmentype.ToString() + "</td></tr>";
                }

                _html += "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Card expiry date</td>"
                + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                + "<td style='width: 25%' align='left'></td>"
                + "<td style='width: 25%' align='left'></td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";
            }
            else
            {
                _html += " "

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";

            }
        }
        return _html;
    }

    public string GenerateCIHTML_Etiqa(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetEtiqaProposal(RefId, InsuranceType);
        string _html = "";
        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            string _name, _unitno, _homeno, _address, _postalcode, _dob, _dd, _mm, _yy, _nationality, _nric, _maritalstatus, _mobile, _occupation;
            string _gender, _expdriving, _vehicleno, _make, _model, _vehicletype, _engineno, _chassisno, _cc, _regyear, _hpstatus, _hpcomp;
            string _insstartdate, _insenddate, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _insstatus,_inscomid, _inscomp, _inspolicyno;
            string _inspldate, _indd, _inmm, _inyy, _ncdreson, _bodytype, _excess, _email, _natureofbusi;
            string _drname1, _drdob1, _drdd1, _drmm1, _dryy1, _drocc1, _drexp1, _drname2, _drdob2, _drdd2, _drmm2, _dryy2, _drocc2, _drexp2;
            string _drname3, _drdob3, _drdd3, _drmm3, _dryy3, _drocc3, _drexp3, _drname4, _drdob4, _drdd4, _drmm4, _dryy4, _drocc4, _drexp4;
            string _drname5, _drdob5, _drdd5, _drmm5, _dryy5, _drocc5, _drexp5, _demeritstatus, _demeritcount, _dmdrname1, _dmdrpoint1;
            string _dmdrname2, _dmdrpoint2, _dmdrname3, _dmdrpoint3, _dmdrname4, _dmdrpoint4, _dmdrname5, _dmdrpoint5, _dmdrname6, _dmdrpoint6;
            string _adddriver, _drcount, _claimstatus, _claim1ststat, _claim1stend; 
            //_nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype,
            string claimamt1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent;
            string _inscancelstatus, _cancelreason, _impairstatus, _impairreason, _planname, _annualpremium;
            string _cxaccountno, _aucode, _nextNCD, _isOFD, _isNCDProtector, _policyno, _orderno;

            DateTime _dofb, _isdate, _iedate, _indate, _drdofb1, _drdofb2, _drdofb3, _drdofb4, _drdofb5;

            _inscancelstatus = ""; _cancelreason = ""; _impairstatus = ""; _impairreason = ""; _demeritstatus = ""; _demeritcount = "";
            _dmdrname1 = ""; _dmdrpoint1 = ""; _dmdrname2 = ""; _dmdrpoint2 = ""; _dmdrname3 = ""; _dmdrpoint3 = ""; _dmdrname4 = "";
            _dmdrpoint4 = ""; _dmdrname5 = ""; _dmdrpoint5 = ""; _dmdrname6 = ""; _dmdrpoint6 = ""; _vehicletype = ""; _expdriving = "";
            _drname1 = ""; _drdob1 = ""; _drdd1 = ""; _drmm1 = ""; _dryy1 = ""; _drocc1 = ""; _drexp1 = "";
            _drname2 = ""; _drdob2 = ""; _drdd2 = ""; _drmm2 = ""; _dryy2 = ""; _drocc2 = ""; _drexp2 = "";
            _drname3 = ""; _drdob3 = ""; _drdd3 = ""; _drmm3 = ""; _dryy3 = ""; _drocc3 = ""; _drexp3 = "";
            _drname4 = ""; _drdob4 = ""; _drdd4 = ""; _drmm4 = ""; _dryy4 = ""; _drocc4 = ""; _drexp4 = "";
            _drname5 = ""; _drdob5 = ""; _drdd5 = ""; _drmm5 = ""; _dryy5 = ""; _drocc5 = ""; _drexp5 = ""; _planname = ""; _annualpremium = "";
            _adddriver = ""; _drcount = ""; 
            //_nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";

            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString();
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();

            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _excess = _dsProposal.Tables[0].Rows[0]["Excess"].ToString();
            _natureofbusi = _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString(); 

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            _expdriving = _dsProposal.Tables[0].Rows[0]["YearDriveSg"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["ContactNo"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasPreInsurer"].ToString() == "True")
            {
                _insstatus = "Yes";
                if (_dsProposal.Tables[2].Rows.Count > 0)
                {
                    _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
                    _inspolicyno = _dsProposal.Tables[0].Rows[0]["PreInsPolicyNo"].ToString();
                    _indate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString());
                    _indd = _indate.Day.ToString("00");
                    _inmm = _indate.Month.ToString("00");
                    _inyy = _indate.Year.ToString();
                    _inspldate = _indd + "/" + _inmm + "/" + _inyy;
                    //_inspldate = _dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString();
                    _inscomid = _dsProposal.Tables[0].Rows[0]["PreInsurerName"].ToString();
                }
                else
                {
                    _insstatus = "No";
                    _inscomp = "Not Applicable";
                    _inspolicyno = "";
                    _inspldate = "";
                    _inscomid = "01";
                }
            }
            else
            {
                _insstatus = "No";
                _inscomp = "Not Applicable";
                _inspolicyno = "";
                _inspldate = "";
                _inscomid = "01";
            }

            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            _nextNCD = _dsProposal.Tables[0].Rows[0]["NCDNextPercent"].ToString();
            _isNCDProtector = _dsProposal.Tables[0].Rows[0]["IsNCDProtector"].ToString();
            _cxaccountno = _dsProposal.Tables[0].Rows[0]["CXAccountNo"].ToString();
            _isOFD = _dsProposal.Tables[0].Rows[0]["IsOffDriveCom"].ToString();
            _policyno = _dsProposal.Tables[0].Rows[0]["PolicyNumber"].ToString();
            _aucode = _dsProposal.Tables[0].Rows[0]["AuCode"].ToString();
            _orderno = _dsProposal.Tables[0].Rows[0]["OrderNo"].ToString();

            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "No NCD(First Policy)";
            }
            else
            {
                _ncdpercent += "%";
            }

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";
                _claimstatus = "No";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString() == "True")
            {
                _inscancelstatus = "Yes";
                _cancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceTerminatedReason"].ToString();
            }
            else
            {
                _inscancelstatus = "No";
                _cancelreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString() == "True")
            {
                _impairstatus = "Yes";
                _impairreason = _dsProposal.Tables[0].Rows[0]["PhysicalImpairmentReason"].ToString();
            }
            else
            {
                _impairstatus = "No";
                _impairreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString() == "True")
            {
                if (_dsProposal.Tables[6].Rows.Count > 0)
                {
                    _demeritstatus = "Yes";
                    _demeritcount = _dsProposal.Tables[6].Rows.Count.ToString();

                    _dmdrname1 = _dsProposal.Tables[6].Rows[0]["DriverName"].ToString();
                    _dmdrpoint1 = _dsProposal.Tables[6].Rows[0]["TotalDemeritPoints"].ToString();
                    if (_dsProposal.Tables[6].Rows.Count > 1)
                    {
                        _dmdrname2 = _dsProposal.Tables[6].Rows[1]["DriverName"].ToString();
                        _dmdrpoint2 = _dsProposal.Tables[6].Rows[1]["TotalDemeritPoints"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 2)
                    {
                        _dmdrname3 = _dsProposal.Tables[6].Rows[2]["DriverName"].ToString();
                        _dmdrpoint3 = _dsProposal.Tables[6].Rows[2]["TotalDemeritPoints"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 3)
                    {
                        _dmdrname4 = _dsProposal.Tables[6].Rows[3]["DriverName"].ToString();
                        _dmdrpoint4 = _dsProposal.Tables[6].Rows[3]["TotalDemeritPoints"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 4)
                    {
                        _dmdrname5 = _dsProposal.Tables[6].Rows[4]["DriverName"].ToString();
                        _dmdrpoint5 = _dsProposal.Tables[6].Rows[4]["TotalDemeritPoints"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 5)
                    {
                        _dmdrname6 = _dsProposal.Tables[6].Rows[5]["DriverName"].ToString();
                        _dmdrpoint6 = _dsProposal.Tables[6].Rows[5]["TotalDemeritPoints"].ToString();
                    }
                }
                else
                {
                    _demeritstatus = "No";
                    _demeritcount = "0";
                }
            }
            else
            {
                _demeritstatus = "No";
                _demeritcount = "0";
            }

            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["RegYear"].ToString();
            _model = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _make = _dsProposal.Tables[5].Rows[0]["Make"].ToString(); ;
            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _vehicletype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString();
            _insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            //_insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString();
            _insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            //_insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hpstatus = "Yes";
                _hpcomp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hpcomp.ToString() == "")
                {
                    _hpcomp = "Not Applicable";
                }
            }
            else
            {
                _hpstatus = "No";
                _hpcomp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drdofb1 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[0]["DOB"].ToString());
                    _drdd1 = _drdofb1.Day.ToString("00");
                    _drmm1 = _drdofb1.Month.ToString("00");
                    _dryy1 = _drdofb1.Year.ToString();
                    //_drdob1 = _drdd1 + "/" + _drmm1 + "/" + _dryy1;
                    _drdob1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drexp1 = _dsProposal.Tables[4].Rows[0]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drdofb2 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[1]["DOB"].ToString());
                    _drdd2 = _drdofb2.Day.ToString("00");
                    _drmm2 = _drdofb2.Month.ToString("00");
                    _dryy2 = _drdofb2.Year.ToString();
                    //_drdob2 = _drdd2 + "/" + _drmm2 + "/" + _dryy2;
                    _drdob2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drexp2 = _dsProposal.Tables[4].Rows[1]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drdofb3 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[2]["DOB"].ToString());
                    _drdd3 = _drdofb3.Day.ToString("00");
                    _drmm3 = _drdofb3.Month.ToString("00");
                    _dryy3 = _drdofb3.Year.ToString();
                    //_drdob3 = _drdd3 + "/" + _drmm3 + "/" + _dryy3;
                    _drdob3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drexp3 = _dsProposal.Tables[4].Rows[2]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drdofb4 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[3]["DOB"].ToString());
                    _drdd4 = _drdofb4.Day.ToString("00");
                    _drmm4 = _drdofb4.Month.ToString("00");
                    _dryy4 = _drdofb4.Year.ToString();
                    //_drdob4 = _drdd4 + "/" + _drmm4 + "/" + _dryy4;
                    _drdob4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drexp4 = _dsProposal.Tables[4].Rows[3]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drdofb5 = Convert.ToDateTime(_dsProposal.Tables[4].Rows[4]["DOB"].ToString());
                    _drdd5 = _drdofb5.Day.ToString("00");
                    _drmm5 = _drdofb5.Month.ToString("00");
                    _dryy5 = _drdofb5.Year.ToString();
                    //_drdob5 = _drdd5 + "/" + _drmm5 + "/" + _dryy5;
                    _drdob5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drexp5 = _dsProposal.Tables[4].Rows[4]["YearOfDrivingInSg"].ToString();
                }
            }

            //_nameofcard = _dsProposal.Tables[0].Rows[0]["NameoftheCard"].ToString();
            //_issuebank = _dsProposal.Tables[0].Rows[0]["IssuingBankName"].ToString();
            //_cno = _dsProposal.Tables[0].Rows[0]["CreditCardNo"].ToString();
            //_ccexmm = _dsProposal.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
            //_ccexyy = _dsProposal.Tables[0].Rows[0]["CardExpiryYear"].ToString().Substring(2, 2);
            //_cctype = _dsProposal.Tables[0].Rows[0]["CardType"].ToString();
            //_ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr>";
            _html += "<tr><td colspan='2'><b>Details of Proposer</b></td><td colspan='2' align='right'><b>Excess Amount</b> : $" + _excess.ToString() + "</td></tr></table>";
            //_html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr></table>";
            _html += "<div><div style='text-align: center'>"
            //_html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Email</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Occupation / Business</td>"
                     + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Contact No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Existing NCD</td>"
                     + "<td width='50%' align='left'>" + _ncdpercent.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>OFD</td>"
                     + "<td width='50%' align='left'>" + _isOFD.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>NRIC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Sex</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Marital Status</td>"
                     + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nature of Business</td>"
                     + "<td width='50%' align='left'>" + _natureofbusi.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Driving Experience</td>"
                     + "<td width='50%' align='left'>" + _expdriving.ToString() + "</td>"
                     + "</tr>"

                      + "<tr>"
                     + "<td width='50%' align='left'>NCD upon renewal</td>"
                     + "<td width='50%' align='left'>" + _nextNCD.ToString() + "</td>"
                     + "</tr>"

                      + "<tr>"
                     + "<td width='50%' align='left'>Is NCDProtector</td>"
                     + "<td width='50%' align='left'>" + _isNCDProtector.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr><td colspan='4' align='left'><b>Particulars of Vehicle</b></td></tr>"

                     + "<tr><td style='width:25%' align='left'>Registration No</td>"
                     + "<td style='width: 25%' align='left'>" + _vehicleno.ToString() + "</td>"
                     + "<td style='width: 25%' align='left'>Year of Registration</td>"
                     + "<td style='width: 25%' align='left'>" + _regyear.ToString() + "</td></tr>"

                     + "<tr><td style='width:25%' align='left'>Make of Vehicle</td>"
                     + "<td style='width: 25%' align='left'>" + _make.ToString() + "</td>"
                     + "<td style='width: 25%' align='left'>Vehicle Model</td>"
                     + "<td style='width: 25%' align='left'>" + _model.ToString() + "</td></tr>"

                     + "<tr><td style='width:25%' align='left'>Vehicle Type</td>"
                     + "<td style='width: 25%' align='left'>" + _vehicletype.ToString() + "</td>"
                     + "<td style='width: 25%' align='left'>Engine capacity</td>"
                     + "<td style='width: 25%' align='left'>" + _cc.ToString() + "cc</td></tr>"

                     + "<tr><td style='width:25%' align='left'>Engine No</td>"
                     + "<td style='width: 25%' align='left'>" + _engineno.ToString() + "</td>"
                     + "<td style='width: 25%' align='left'>Chassis No</td>"
                     + "<td style='width: 25%' align='left'>" + _chassisno.ToString() + "</td></tr>"

                     + "<tr><td colspan='4' align='left'><b>Additional drivers : </b>" + _adddriver.ToString() + "</td></tr>";

                    if (Convert.ToInt16(_drcount) > 0)
                    {
                        _html += "<tr><td colspan='4' align='left'>Driver 1</td></tr>"
                        + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _drname1.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Date of Birth</td>"
                        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob1.ToString() + "</td></tr>"

                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                        + "<td style='width: 25%' align='left'>" + _drocc1.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Driving Experience</td>"
                        + "<td style='width: 25%' align='left'>" + _drexp1.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_drcount) > 1)
                    {
                        _html += "<tr><td colspan='4' align='left'>Driver 2</td></tr>"
                        + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _drname2.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Date of Birth</td>"
                        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob2.ToString() + "</td></tr>"

                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                        + "<td style='width: 25%' align='left'>" + _drocc2.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Driving Experience</td>"
                        + "<td style='width: 25%' align='left'>" + _drexp2.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_drcount) > 2)
                    {
                        _html += "<tr><td colspan='4' align='left'>Driver 3</td></tr>"
                        + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _drname3.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Date of Birth</td>"
                        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob3.ToString() + "</td></tr>"

                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                        + "<td style='width: 25%' align='left'>" + _drocc3.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Driving Experience</td>"
                        + "<td style='width: 25%' align='left'>" + _drexp3.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_drcount) > 3)
                    {
                        _html += "<tr><td colspan='4' align='left'>Driver 4</td></tr>"
                        + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _drname4.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Date of Birth</td>"
                        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob4.ToString() + "</td></tr>"

                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                        + "<td style='width: 25%' align='left'>" + _drocc4.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Driving Experience</td>"
                        + "<td style='width: 25%' align='left'>" + _drexp4.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_drcount) > 4)
                    {
                        _html += "<tr><td colspan='4' align='left'>Driver 5</td></tr>"
                        + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _drname5.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Date of Birth</td>"
                        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _drdob5.ToString() + "</td></tr>"

                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                        + "<td style='width: 25%' align='left'>" + _drocc5.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Driving Experience</td>"
                        + "<td style='width: 25%' align='left'>" + _drexp5.ToString() + "</td></tr>";
                    }

                    _html += "<tr><td colspan='4' align='left'>Period of insurance</td></tr>"

                    + "<tr><td style='width:25%' align='left'>From</td>"
                    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>To</td>"
                    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Is this vehicle under Hire Purchase?</td>"
                    + "<td style='width: 25%' align='left'>" + _hpstatus.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Name of finance Company</td>"
                    + "<td style='width: 25%' align='left'>" + _hpcomp.ToString() + "</td></tr>";

                    if (_insstatus == "Yes" && _inscomid != "01" && _inscomid != "177")
                    {
                        _html += "<tr><td style='width: 25%' align='left'>Current Insurance Company</td>"
                                + "<td colspan='3' align='left'>" + _inscomp.ToString() + "</td></tr>"

                                + "<tr><td style='width:25%' align='left'>Policy No.</td>"
                                + "<td style='width:25%' align='left'>" + _inspolicyno.ToString() + "</td>"
                                + "<td style='width: 25%' align='left'>Expiry Date</td>"
                                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _inspldate.ToString() + "</td></tr>";
                    }
                    else
                    {
                        _html += "<tr><td style='width: 25%' align='left'>Current Insurance Company</td>"
                                + "<td colspan='3' align='left'>" + _inscomp.ToString() + "</td></tr>";
                    }
                    _html += "<tr>"
                    + "<td colspan='4' align='left'>Claim history o proposer & named / Authorised Driver(s)(Last 3 years) : " + _claimstatus.ToString() + "</td>"
                    + "</tr>";
                    if (_claimstatus.ToString() == "Yes")
                    {
                        if (claimamt1.ToString() != "0" && claimamt1.ToString() != "")
                        {
                            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                            + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
                            + "<td style='width: 25%' align='left'> Claim Amount</td>"
                            + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
                        }
                        if (claimamt2.ToString() != "0" && claimamt2.ToString() != "")
                        {
                            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
                            + "<td style='width: 25%' align='left'> Claim Amount</td>"
                            + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
                        }
                        if (claimamt3.ToString() != "0" && claimamt3.ToString() != "")
                        {
                            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
                            + "<td style='width: 25%' align='left'> Claim Amount</td>"
                            + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
                        }
                    }

                    _html += "<tr><td colspan='4' align='left'><b>General Questions</td></tr>"

                    + "<tr><td colspan='3' align='left'>Have you or your named driver(s) been given / accumulated demerit points during the last 24 months?</td>"
                    + "<td style='width: 25%' align='left'>" + _demeritstatus.ToString() + "</td></tr>";
                    if (Convert.ToInt16(_demeritcount) > 0)
                    {
                        _html += "<tr><td style='width:25%' align='left'>1. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname1.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint1.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_demeritcount) > 1)
                    {
                        _html += "<tr><td style='width:25%' align='left'>2. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname2.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint2.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_demeritcount) > 2)
                    {
                        _html += "<tr><td style='width:25%' align='left'>3. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname3.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint3.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_demeritcount) > 3)
                    {
                        _html += "<tr><td style='width:25%' align='left'>4. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname4.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint4.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_demeritcount) > 4)
                    {
                        _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname5.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint5.ToString() + "</td></tr>";
                    }
                    if (Convert.ToInt16(_demeritcount) > 5)
                    {
                        _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrname6.ToString() + "</td>"
                        + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                        + "<td style='width: 25%' align='left'>" + _dmdrpoint6.ToString() + "</td></tr>";
                    }
                    _html += "<tr><td colspan='3' align='left'>Have you or your named driver(s) had any motor insurance proposal declined, cancelled or renewal rejected by any insurance company?</td>"
                    + "<td style='width: 25%' align='left'>" + _inscancelstatus.ToString() + "</td></tr>";
                    if (_inscancelstatus.ToString() == "Yes")
                    {
                        _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                        + "<td colspan='3' align='left'>" + _cancelreason.ToString() + "</td></tr>";
                    }
                    _html += "<tr><td colspan='3' align='left'>Have you or your named driver(s) suffered any disease or infirmity that could impair the ability to drive?</td>"
                            + "<td style='width: 25%' align='left'>" + _impairstatus.ToString() + "</td></tr>";
                    if (_inscancelstatus.ToString() == "Yes")
                    {
                        _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                        + "<td colspan='3' align='left'>" + _impairreason.ToString() + "</td></tr>";
                    }

                    _html += "<tr><td colspan='4' align='left'></td></tr>";
                    _html += "<tr><td>Account No.</td><td>[" + _cxaccountno + "]</td><td>Policy No.</td><td>[" + _policyno + "]</td></tr>";
                    _html += "<tr><td>Order No.</td><td>[" + _orderno + "]</td><td>AuCode</td><td>[" + _aucode + "]</td></tr>";

                    _html += "</table>"
                    + "</td>"
                    + "</tr>"

                    + "</table>"
                    + "</div></div>";
        }
        return _html;
    }

    public string GenerateCIHTML_Liberty(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetLibertyProposal(RefId, InsuranceType);
        string _html = "";
        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            string _name, _unitno, _homeno, _address, _postalcode, _dob, _dd, _mm, _yy, _nationality, _nric, _maritalstatus, _officeno, _mobile;
            string _gender, _expdriving, _vehicleno, _make, _model, _vehicletype, _engineno, _chassisno, _cc, _regyear, _mfgyear, _hpstatus, _hpcomp;
            string _insstartdate, _insenddate, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _insstatus, _inscomp, _inscomid, _insvhleno, _insncdentitle;
            string _inspldate, _indd, _inmm, _inyy, _ncdreson, _bodytype, _occupation, _empname, _drwestmylsa, _vhlemodifystatus, _vhlemodifyreason;
            string _drname1, _drage1, _drgender1, _drmarital1, _drocc1, _drexp1, _drname2, _drage2, _drgender2, _drmarital2, _drocc2, _drexp2;
            string _drname3, _drage3, _drgender3, _drmarital3, _drocc3, _drexp3, _drname4, _drage4, _drgender4, _drmarital4, _drocc4, _drexp4;
            string _drname5, _drage5, _drgender5, _drmarital5, _drocc5, _drexp5, _demeritstatus, _demeritcount, _dmdrname1, _dmdrpoint1, _producerCode;
            string _dmdrdate1, _dmdrtype1, _dmdrname2, _dmdrpoint2, _dmdrdate2, _dmdrtype2, _dmdrname3, _dmdrpoint3, _dmdrdate3, _dmdrtype3;
            string _dmdrname4, _dmdrpoint4, _dmdrdate4, _dmdrtype4, _dmdrname5, _dmdrpoint5, _dmdrdate5, _dmdrtype5, _dmdrname6, _dmdrpoint6;
            string _dmdrdate6, _dmdrtype6, _adddriver, _drcount, _paymenttype, _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _installmentype, _claimstatus, _claim1ststat, _claim1stend;
            string _claimcount1, claimamt1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _ncdnil;
            string _inscancelstatus, _cancelreason, _impairstatus, _impairreason, _accessorystatus, _accessorydetail, _convictedstatus, _convictedreason, _planname, _annualpremium, _agerestriction;
            string _email, _nextncd, _isoffpeak;

            DateTime _dofb, _isdate, _iedate, _indate;

            _inscancelstatus = ""; _cancelreason = ""; _impairstatus = ""; _impairreason = ""; _demeritstatus = ""; _demeritcount = "";
            _dmdrname1 = ""; _dmdrpoint1 = ""; _dmdrdate1 = ""; _dmdrtype1 = ""; _dmdrname2 = ""; _dmdrpoint2 = ""; _dmdrdate2 = ""; _dmdrtype2 = "";
            _dmdrname3 = ""; _dmdrpoint3 = ""; _dmdrdate3 = ""; _dmdrtype3 = ""; _dmdrname4 = ""; _dmdrdate4 = ""; _dmdrtype4 = "";
            _dmdrpoint4 = ""; _dmdrname5 = ""; _dmdrpoint5 = ""; _dmdrdate5 = ""; _dmdrtype5 = ""; _dmdrname6 = ""; _producerCode = "D9999-CX";
            _dmdrpoint6 = ""; _dmdrdate6 = ""; _dmdrtype6 = ""; _vehicletype = ""; _expdriving = "";
            _drname1 = ""; _drage1 = ""; _drgender1 = ""; _drmarital1 = ""; _drocc1 = ""; _drexp1 = "";
            _drname2 = ""; _drage2 = ""; _drgender2 = ""; _drmarital2 = ""; _drocc2 = ""; _drexp2 = "";
            _drname3 = ""; _drage3 = ""; _drgender3 = ""; _drmarital3 = ""; _drocc3 = ""; _drexp3 = "";
            _drname4 = ""; _drage4 = ""; _drgender4 = ""; _drmarital4 = ""; _drocc4 = ""; _drexp4 = "";
            _drname5 = ""; _drage5 = ""; _drgender5 = ""; _drmarital5 = ""; _drocc5 = ""; _drexp5 = ""; _planname = ""; _annualpremium = ""; _agerestriction = "0";
            _adddriver = ""; _drcount = ""; _paymenttype = ""; _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = ""; _installmentype = "";
            _email = ""; _isoffpeak = "";

            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString();
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            //Cheryl on 28 June 2011            
            if (_dsProposal.Tables[0].Rows[0]["Offbeak"].ToString() == "Yes")
            {
                _isoffpeak = "Weekend Use";
            }
            else
            {
                _isoffpeak = "Private Use";
            }
            

            //Sakthi on 10 Jan 2011 - start
            if (_dsProposal.Tables[0].Rows[0]["NInfo5"].ToString() != null)
            {
                _agerestriction = _dsProposal.Tables[0].Rows[0]["NInfo5"].ToString();
            }
            //Sakthi on 10 Jan 2011 - end

            _drwestmylsa = _dsProposal.Tables[0].Rows[0]["DrWMalaysia"].ToString();
            _expdriving = _dsProposal.Tables[0].Rows[0]["YearDriveSg"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officeno = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpNameandTrade"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["Ninfo1"] != null && _dsProposal.Tables[0].Rows[0]["Ninfo1"].ToString() != "")
            {
                Int64 _Agent = Convert.ToInt64(_dsProposal.Tables[0].Rows[0]["Ninfo1"].ToString());
                if (_Agent == 0)
                {
                    _producerCode = "D9999-CX";
                }
                else
                {
                    _producerCode = "D9999-TD";
                }
            }
            else
            {
                _producerCode = "D9999-CX";
            }

            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasPreInsurer"].ToString() == "True")
            {
                _insstatus = "Yes";
                if (_dsProposal.Tables[2].Rows.Count > 0)
                {
                    _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
                    _insvhleno = _dsProposal.Tables[0].Rows[0]["PreInsVechicleNo"].ToString();
                    _indate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString());
                    _indd = _indate.Day.ToString("00");
                    _inmm = _indate.Month.ToString("00");
                    _inyy = _indate.Year.ToString();
                   // _inspldate = _dd + "/" + _mm + "/" + _yy;
                    //_inspldate = _dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString();
                    _inspldate = _indate.ToString("dd-MMM-yyyy");
                    _inscomid = _dsProposal.Tables[0].Rows[0]["PreInsurerName"].ToString();
                    if (_dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() == "-1")
                    {
                        _insncdentitle = "";
                    }
                    else
                    {
                        _insncdentitle = _dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString();
                    }
                }
                else
                {
                    _insstatus = "Not Applicable";
                    _inscomp = "Not Applicable";
                    _insvhleno = "";
                    _inspldate = "";
                    _insncdentitle = "";
                    _inscomid = "01";
                }
            }
            else
            {
                _insstatus = "Not Applicable";
                _inscomp = "Not Applicable";
                _insvhleno = "";
                _inspldate = "";
                _insncdentitle = "";
                _inscomid = "01";
            }

            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "No NCD(First Policy)";
            }
            else
            {
                _ncdpercent += "%";
            }
            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            _nextncd = _dsProposal.Tables[0].Rows[0]["NextNCD"].ToString() + "%";
            if (_ncdreson == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson == "-1")
            {
                _ncdreson = "";
            }

            _paymenttype = _dsProposal.Tables[0].Rows[0]["PamentType"].ToString();

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";
                _claimstatus = "No";
                _ncdpercent = "0%";
            }
            //_ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            //if (_ncdpercent.ToString() == "-1")
            //{
            //    _ncdpercent = "10%";
            //}
            //else
            //{
            //    if (_claimstatus == "No")
            //    {
            //        _ncdpercent = NoNCD(_ncdpercent);
            //    }
            //    else if (_claimstatus == "Yes" && _claimcount1 == "0")
            //    {
            //        _ncdpercent = NoNCD(_ncdpercent);
            //    }
            //    else if (_claimstatus == "Yes" && _claimcount1 == "1")
            //    {
            //        _ncdpercent = OneTimesNCD(_ncdpercent);
            //    }
            //    else
            //    {
            //        _ncdpercent = "0%";
            //    }
            //}
            if (_dsProposal.Tables[0].Rows[0]["HasVechicleModified"].ToString() == "True")
            {
                _vhlemodifystatus = "Yes";
                _vhlemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
            }
            else
            {
                _vhlemodifystatus = "No";
                _vhlemodifyreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString() == "True")
            {
                _inscancelstatus = "Yes";
                _cancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceTerminatedReason"].ToString();
            }
            else
            {
                _inscancelstatus = "No";
                _cancelreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString() == "True")
            {
                _impairstatus = "Yes";
                _impairreason = _dsProposal.Tables[0].Rows[0]["PhysicalImpairmentReason"].ToString();
            }
            else
            {
                _impairstatus = "No";
                _impairreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasConvictedMoterOffence"].ToString() == "True")
            {
                _convictedstatus = "Yes";
                _convictedreason = _dsProposal.Tables[0].Rows[0]["ConvictedReason"].ToString();
            }
            else
            {
                _convictedstatus = "No";
                _convictedreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasAccessory"].ToString() == "True")
            {
                _accessorystatus = "Yes";
                _accessorydetail = _dsProposal.Tables[0].Rows[0]["AccessoryDescription"].ToString();
            }
            else
            {
                _accessorystatus = "No";
                _accessorydetail = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString() == "True")
            {
                if (_dsProposal.Tables[6].Rows.Count > 0)
                {
                    _demeritstatus = "Yes";
                    _demeritcount = _dsProposal.Tables[6].Rows.Count.ToString();

                    _dmdrname1 = _dsProposal.Tables[6].Rows[0]["DriverName"].ToString();
                    _dmdrpoint1 = _dsProposal.Tables[6].Rows[0]["TotalDemeritPoints"].ToString();
                    _dmdrdate1 = _dsProposal.Tables[6].Rows[0]["DemeritDate"].ToString();
                    _dmdrtype1 = _dsProposal.Tables[6].Rows[0]["TypeofOffence"].ToString();
                    if (_dsProposal.Tables[6].Rows.Count > 1)
                    {
                        _dmdrname2 = _dsProposal.Tables[6].Rows[1]["DriverName"].ToString();
                        _dmdrpoint2 = _dsProposal.Tables[6].Rows[1]["TotalDemeritPoints"].ToString();
                        _dmdrdate2 = _dsProposal.Tables[6].Rows[1]["DemeritDate"].ToString();
                        _dmdrtype2 = _dsProposal.Tables[6].Rows[1]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 2)
                    {
                        _dmdrname3 = _dsProposal.Tables[6].Rows[2]["DriverName"].ToString();
                        _dmdrpoint3 = _dsProposal.Tables[6].Rows[2]["TotalDemeritPoints"].ToString();
                        _dmdrdate3 = _dsProposal.Tables[6].Rows[2]["DemeritDate"].ToString();
                        _dmdrtype3 = _dsProposal.Tables[6].Rows[2]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 3)
                    {
                        _dmdrname4 = _dsProposal.Tables[6].Rows[3]["DriverName"].ToString();
                        _dmdrpoint4 = _dsProposal.Tables[6].Rows[3]["TotalDemeritPoints"].ToString();
                        _dmdrdate4 = _dsProposal.Tables[6].Rows[3]["DemeritDate"].ToString();
                        _dmdrtype4 = _dsProposal.Tables[6].Rows[3]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 4)
                    {
                        _dmdrname5 = _dsProposal.Tables[6].Rows[4]["DriverName"].ToString();
                        _dmdrpoint5 = _dsProposal.Tables[6].Rows[4]["TotalDemeritPoints"].ToString();
                        _dmdrdate5 = _dsProposal.Tables[6].Rows[4]["DemeritDate"].ToString();
                        _dmdrtype5 = _dsProposal.Tables[6].Rows[4]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 5)
                    {
                        _dmdrname6 = _dsProposal.Tables[6].Rows[5]["DriverName"].ToString();
                        _dmdrpoint6 = _dsProposal.Tables[6].Rows[5]["TotalDemeritPoints"].ToString();
                        _dmdrdate6 = _dsProposal.Tables[6].Rows[5]["DemeritDate"].ToString();
                        _dmdrtype6 = _dsProposal.Tables[6].Rows[5]["TypeofOffence"].ToString();
                    }
                }
                else
                {
                    _demeritstatus = "No";
                    _demeritcount = "0";
                }
            }
            else
            {
                _demeritstatus = "No";
                _demeritcount = "0";
            }

            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _mfgyear = _dsProposal.Tables[0].Rows[0]["ManufactYear"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["DateofReg"].ToString();
            _model = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _make = _dsProposal.Tables[5].Rows[0]["Make"].ToString();
            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _vehicletype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString();
            _insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            //_insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString();
            _insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            //_insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hpstatus = "Yes";
                _hpcomp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hpcomp.ToString() == "")
                {
                    _hpcomp = "Not Applicable";
                }
            }
            else
            {
                _hpstatus = "No";
                _hpcomp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drage1 = _dsProposal.Tables[4].Rows[0]["Age"].ToString();
                    _drgender1 = _dsProposal.Tables[4].Rows[0]["Gender"].ToString();
                    _drmarital1 = _dsProposal.Tables[4].Rows[0]["Marital"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drexp1 = _dsProposal.Tables[4].Rows[0]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drage2 = _dsProposal.Tables[4].Rows[1]["Age"].ToString();
                    _drgender2 = _dsProposal.Tables[4].Rows[1]["Gender"].ToString();
                    _drmarital2 = _dsProposal.Tables[4].Rows[1]["Marital"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drexp2 = _dsProposal.Tables[4].Rows[1]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drage3 = _dsProposal.Tables[4].Rows[2]["Age"].ToString();
                    _drgender3 = _dsProposal.Tables[4].Rows[2]["Gender"].ToString();
                    _drmarital3 = _dsProposal.Tables[4].Rows[2]["Marital"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drexp3 = _dsProposal.Tables[4].Rows[2]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drage4 = _dsProposal.Tables[4].Rows[3]["Age"].ToString();
                    _drgender4 = _dsProposal.Tables[4].Rows[3]["Gender"].ToString();
                    _drmarital4 = _dsProposal.Tables[4].Rows[3]["Marital"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drexp4 = _dsProposal.Tables[4].Rows[3]["YearOfDrivingInSg"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drage5 = _dsProposal.Tables[4].Rows[4]["Age"].ToString();
                    _drgender5 = _dsProposal.Tables[4].Rows[4]["Gender"].ToString();
                    _drmarital5 = _dsProposal.Tables[4].Rows[4]["Marital"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drexp5 = _dsProposal.Tables[4].Rows[4]["YearOfDrivingInSg"].ToString();
                }
            }
            //_nameofcard = _dsProposal.Tables[0].Rows[0]["NameoftheCard"].ToString();
            //_issuebank = _dsProposal.Tables[0].Rows[0]["IssuingBankName"].ToString();
            //_cno = _dsProposal.Tables[0].Rows[0]["CreditCardNo"].ToString();
            //_ccexmm = _dsProposal.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
            //_ccexyy = _dsProposal.Tables[0].Rows[0]["CardExpiryYear"].ToString();
            //_cctype = _dsProposal.Tables[0].Rows[0]["CardType"].ToString();
            //_ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);

            DataSet _dsPayment = new DataSet();
            if (_paymenttype == "CreditCard")
            {
                _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 29, InsuranceType);
                if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
                {
                    _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                    _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                    _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                    _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                    _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                    _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                    _installmentype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();

                    if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                        _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                    else
                        _ccno = "";
                }
            }
            _html = "<table>";
            if (_agerestriction == "1")
            {
                _html += "<tr><td colspan='4' align='right'>Driving restricted to Policyholder only : less 10%</td></tr>";
            }
            else if (_agerestriction == "2")
            {
                _html += "<tr><td colspan='4' align='right'>Driving restricted to Policyholder and 1 named driver only : less 7.5%</td></tr>";
            }
            _html += "<tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr>";
            _html += "</table>";
            //_html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr></table>";
            _html += "<div><div>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr>"
                     + "<td width='50%' colspan='2'><b>Details of Proposer</b></td>"
                     + "<td width='50%' colspan='2' align='right'><b>Producer Code</b> : " + _producerCode.ToString() + "</td>" 
                     + "</tr>"
                     + "</table>"
                     + "</div><div style='text-align: center'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Email</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Occupation / Business</td>"
                     + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Mobile No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Tel. No(O)</td>"
                     + "<td width='50%' align='left'>" + _officeno.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>NRIC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Sex</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Marital Status</td>"
                     + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Driving Experience</td>"
                     + "<td width='50%' align='left'>" + _expdriving.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Employer's Name & Trade</td>"
                     + "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td colspan='4' align='left'>Claim Experience(Past 3 years) : " + _claimstatus.ToString() + "</td>"
                    + "</tr>";
            if (_claimstatus.ToString() == "Yes")
            {
                if (claimamt1.ToString() != "0" && claimamt1.ToString() != "")
                {
                    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                    + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Claim Amount</td>"
                    + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
                }
                if (claimamt2.ToString() != "0" && claimamt2.ToString() != "")
                {
                    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Claim Amount</td>"
                    + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
                }
                if (claimamt3.ToString() != "0" && claimamt3.ToString() != "")
                {
                    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
                    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'> Claim Amount</td>"
                    + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
                }
            }
            _html += "<tr><td style='width:25%' align='left'>NCD on next renewal (%)</td>"
            + "<td colspan='3' align='left'>" + _nextncd.ToString() + "</td></tr>";

            if (_drwestmylsa != "")
            {
                _html += "<tr><td colspan='4' align='left'>How often do you drive to West Malaysia : " + _drwestmylsa.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='4' align='left'>Usage : " + _isoffpeak.ToString() + "</td></tr>";

            _html += "<tr><td colspan='4' align='left'><b>Details of Vehicle</b></td></tr>"

             + "<tr><td style='width:25%' align='left'>Registration No</td>"
             + "<td style='width: 25%' align='left'>" + _vehicleno.ToString().ToUpper() + "</td>"
             + "<td style='width: 25%' align='left'>Year of Manufacture</td>"
             + "<td style='width: 25%' align='left'>" + _mfgyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Make/Model</td>"
             + "<td style='width: 25%' align='left'>" + _make.ToString() + "/" + _model.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Registration Date</td>"
             + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _regyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Body Type</td>"
             + "<td style='width: 25%' align='left'>" + _vehicletype.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>CC</td>"
             + "<td style='width: 25%' align='left'>" + _cc.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Engine No</td>"
             + "<td style='width: 25%' align='left'>" + _engineno.ToString().ToUpper() + "</td>"
             + "<td style='width: 25%' align='left'>Chassis No</td>"
             + "<td style='width: 25%' align='left'>" + _chassisno.ToString().ToUpper() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Any hire purchase to your motor vehicle?</td>"
             + "<td style='width: 25%' align='left'>" + _hpstatus.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Hire Purchase Company</td>"
             + "<td style='width: 25%' align='left'>" + _hpcomp.ToString() + "</td></tr>";

            if (_insstatus == "Yes" && _inscomid != "01" && _inscomid != "177")
            {
                _html += "<tr><td colspan='4' align='left'>Do you have any motor vehicle Insurance? " + _insstatus.ToString() + "</td></tr>";
            }
            else
            {
                _html += "<tr><td colspan='4' align='left'>Do you have any motor vehicle Insurance? " + _inscomp.ToString() + "</td></tr>";
            }

            if (_insstatus.ToString() == "Yes" && _inscomid != "01" && _inscomid != "177")
            {
                _html += "<tr><td style='width:25%' align='left'>Current Insurance Co.</td>"
                + "<td style='width: 25%' align='left'>" + _inscomp.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Vehicle No.</td>"
                + "<td style='width: 25%' align='left'>" + _insvhleno.ToString().ToUpper() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Expiry / Cancellation Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _inspldate.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>NCD (No Claims Discount) entitlement</td>"
                + "<td style='width: 25%' align='left'>" + _insncdentitle.ToString() + "</td></tr>";
            }
            //else
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Current Insurance Co.</td>"
            //    + "<td colspan='3' align='left'>" + _inscomp.ToString() + "</td></tr>";
            //}

            _html += "<tr>"
            + "<td colspan='4' align='left'>If NCD is NIL, please provide the reason : " + _ncdreson.ToString() + "</td>"
            + "</tr>"

            + "<tr><td colspan='4' align='left'>Has the vehicle been modified/converted in anyway from the manufacturer's specifications? " + _vhlemodifystatus.ToString() + "</td></tr>";
            if (_vhlemodifystatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Reason</td>"
                     + "<td colspan'3' align='left'>" + _vhlemodifyreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='4' align='left'>Are there any additional accessories installed on the vehicle? " + _accessorystatus.ToString() + "</td></tr>";
            if (_vhlemodifystatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Accessories Details</td>"
                     + "<td colspan'3' align='left'>" + _accessorydetail.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='4' align='left'>Period of insurance</td></tr>"

            + "<tr><td style='width:25%' align='left'>From</td>"
            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
            + "<td style='width: 25%' align='left'>To</td>"
            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td></tr>"

            + "<tr><td colspan='4' align='left'><b>Additional drivers : </b>" + _adddriver.ToString() + "</td></tr>";
            if (Convert.ToInt16(_drcount) > 0)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 1</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Age</td>"
                + "<td style='width: 25%' align='left'>" + _drage1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Gender</td>"
                + "<td style='width: 25%' align='left'>" + _drgender1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Marital Status</td>"
                + "<td style='width: 25%' align='left'>" + _drmarital1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Driving Experience</td>"
                + "<td style='width: 25%' align='left'>" + _drexp1.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 1)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 2</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Age</td>"
                + "<td style='width: 25%' align='left'>" + _drage2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Gender</td>"
                + "<td style='width: 25%' align='left'>" + _drgender2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Marital Status</td>"
                + "<td style='width: 25%' align='left'>" + _drmarital2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Driving Experience</td>"
                + "<td style='width: 25%' align='left'>" + _drexp2.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 2)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 3</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Age</td>"
                + "<td style='width: 25%' align='left'>" + _drage3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Gender</td>"
                + "<td style='width: 25%' align='left'>" + _drgender3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Marital Status</td>"
                + "<td style='width: 25%' align='left'>" + _drmarital3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Driving Experience</td>"
                + "<td style='width: 25%' align='left'>" + _drexp3.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 3)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 4</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Age</td>"
                + "<td style='width: 25%' align='left'>" + _drage4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Gender</td>"
                + "<td style='width: 25%' align='left'>" + _drgender4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Marital Status</td>"
                + "<td style='width: 25%' align='left'>" + _drmarital4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Driving Experience</td>"
                + "<td style='width: 25%' align='left'>" + _drexp4.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_drcount) > 4)
            {
                _html += "<tr><td colspan='4' align='left'>Driver 5</td></tr>"
                + "<tr><td style='width:25%' align='left'>Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _drname5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Age</td>"
                + "<td style='width: 25%' align='left'>" + _drage5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Gender</td>"
                + "<td style='width: 25%' align='left'>" + _drgender5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Marital Status</td>"
                + "<td style='width: 25%' align='left'>" + _drmarital5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _drocc5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Driving Experience</td>"
                + "<td style='width: 25%' align='left'>" + _drexp5.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='4' align='left'><b>Other Information</td></tr>"

             + "<tr><td colspan='4' align='left'>Been convicted of any motoring offence (other than parking) in the past 3 years or have prosecutions pending? " + _convictedstatus.ToString() + "</td></tr>";
            if (_vhlemodifystatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Reason</td>"
                     + "<td colspan'3' align='left'>" + _convictedreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>Have you or your named driver(s) been given / accumulated demerit points during the last 24 months?</td>"
            + "<td style='width: 25%' align='left'>" + _demeritstatus.ToString() + "</td></tr>";
            if (Convert.ToInt16(_demeritcount) > 0)
            {
                _html += "<tr><td style='width:25%' align='left'>1. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate1.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 1)
            {
                _html += "<tr><td style='width:25%' align='left'>2. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate2.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 2)
            {
                _html += "<tr><td style='width:25%' align='left'>3. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate3.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 3)
            {
                _html += "<tr><td style='width:25%' align='left'>4. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate4.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 4)
            {
                _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate5.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 5)
            {
                _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname6.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint6.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype6.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate6.ToString() + "</td></tr>";
            }
            _html += "<tr><td colspan='3' align='left'>Has physical impairment which will affect the driving ability?</td>"
            + "<td style='width: 25%' align='left'>" + _impairstatus.ToString() + "</td></tr>";
            if (_impairstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _impairreason.ToString() + "</td></tr>";
            }
            _html += "<tr><td colspan='3' align='left'>Do you have any insurance terminated in the last 12 months due to a breach of any premium payment condition?</td>"
                    + "<td style='width: 25%' align='left'>" + _inscancelstatus.ToString() + "</td></tr>";
            if (_inscancelstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _cancelreason.ToString() + "</td></tr>";
            }

            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetCarDownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Details</b></td></tr>"

                + "<tr><td style='width:25%' align='left'>Payment Mode</td>"
                + "<td style='width: 25%' align='left'>" + _paymenttype.ToString() + "</td>";

                if (_paymenttype == "Cash")
                {
                    _html += "<td style='width: 25%' align='left'></td>"
                    + "<td style='width: 25%' align='left'></td></tr>";
                }
                else
                {
                    _html += "<td style='width: 25%' align='left'>Installment Type</td>"
                    + "<td style='width: 25%' align='left'>" + _installmentype.ToString() + "</td></tr>";
                    
                    _html += "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                    + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                    + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                    + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Card expiry date</td>"
                    + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                    + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                    + "<td style='width: 25%' align='left'></td>"
                    + "<td style='width: 25%' align='left'></td></tr>";
                }

                _html += "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";
            }
            else
            {
                _html += " "

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";

            }
            //_html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
            //+ "<tr><td style='width:25%' align='left'>Name of the Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Issuing Bank</td>"
            //+ "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
            //+ "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Card expiry date</td>"
            //+ "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Type of Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'></td>"
            //+ "<td style='width: 25%' align='left'></td></tr>"

            //+ "</table>"
            //+ "</td>"
            //+ "</tr>"

            //+ "</table>"
            //+ "</div></div>";
        }
        return _html;
    }

    public string GenerateTIHTML_Hsbc(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetHSBCProposal(RefId, InsuranceType);
        string _html = "";
        if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
        //if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            string _name, _dob, _sdob, _nationality, _nric, _mobile, _hoemphone, _officephone, _faxno, _unitno, _homeno, _address;
            string _postalcode, _empname, _email, _dd, _mm, _yy;
            string _gender, _insurergender, _spousegender, _childgender1, _childgender2, _childgender3, _childgender4, _childgender5, _childgender6;
            string _plantype, _triptype, _countryarea, _nooftravellers, _totalpremium;
            string _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _planname;
            DateTime _dofb = CE.Global.General.GetUTCDateTime(), _startdate, _enddate;
            string _noofadults = "0";
            string quoteref = General.GetRefNumber(RefId);

            _name = ""; _dob = ""; _nationality = ""; _nric = ""; _mobile = ""; _hoemphone = ""; _officephone = "";
            _faxno = ""; _unitno = ""; _homeno = ""; _address = ""; _postalcode = ""; _empname = ""; _email = "";
            _dd = ""; _mm = ""; _yy = ""; _plantype = ""; _triptype = ""; _countryarea = ""; _nooftravellers = ""; _totalpremium = "";
            _nameofcard = ""; _issuebank = ""; _ccno = ""; _cno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = ""; _planname = "";

            _gender = ""; _insurergender = ""; _spousegender = ""; _childgender1 = ""; _childgender2 = ""; 
            _childgender3 = ""; _childgender4 = ""; _childgender5 = ""; _childgender6 = "";

            string _insname, _insdob, _insnric, _sponame, _spodob, _sponric, _childname1, _childdob1, _childnric1, _childname2, _childdob2, _childnric2;
            string _childname3, _childdob3, _childnric3, _childname4, _childdob4, _childnric4, _childname5, _childdob5, _childnric5;
            string _childname6, _childdob6, _childnric6, _noofchilds, _spousestatus;

            _insname = ""; _insdob = ""; _insnric = ""; _sponame = ""; _spodob = ""; _sponric = ""; _childname1 = ""; _childdob1 = ""; _childnric1 = "";
            _childname2 = ""; _childdob2 = ""; _childnric2 = ""; _childname3 = ""; _childdob3 = ""; _childnric3 = ""; _childname4 = ""; _childdob4 = ""; 
            _childnric4 = ""; _childname5 = ""; _childdob5 = ""; _childnric5 = ""; _childname6 = ""; _childdob6 = ""; _childnric6 = ""; _noofchilds = "0";
            _spousestatus = "No";

            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpName"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _noofadults = _dsProposal.Tables[0].Rows[0]["NoOfAdults"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _plantype = _dsProposal.Tables[0].Rows[0]["PlanType"].ToString();

            if(_dsProposal.Tables[0].Rows[0]["Gender"].ToString() != null && _dsProposal.Tables[0].Rows[0]["Gender"].ToString() != "")
            {
                _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                if (_gender == "M")
                    _gender = "Male";
                else
                    _gender = "Female";
            
            }

            if (_plantype == "Family")
            {
                //_dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["Info3"].ToString());
                _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                _sdob = _dsProposal.Tables[0].Rows[0]["SDOB"].ToString();
            }
            else
            {
                //_dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
                _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                _sdob = _dsProposal.Tables[0].Rows[0]["SDOB"].ToString();
            }

            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString().Substring(2, 2);


            _totalpremium = _dsProposal.Tables[0].Rows[0]["TotalPremium"].ToString();

            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _faxno = _dsProposal.Tables[0].Rows[0]["FaxNo"].ToString();

            _triptype = _dsProposal.Tables[0].Rows[0]["TripType"].ToString();
            _countryarea = _dsProposal.Tables[0].Rows[0]["Country"].ToString();
            _nooftravellers = _dsProposal.Tables[0].Rows[0]["NoOfTravellers"].ToString();
            _startdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _enddate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());

            

            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 23, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            string _newplantype = "";
            if (_noofadults == "1" && _plantype == "Family")
                _newplantype = "Family : Individual + Child";
            else
                _newplantype = _plantype;

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + " (" + _newplantype + ")</td>"
                    + "<td colspan='2' align='right'><b>Total Premium</b> (w/GST) : $" + _totalpremium.ToString() + "</td>"
                    + "<tr><td width='25%'><b>Quote Reference</b></td><td>TIH" + quoteref + "</td>"
                    + "<td colspan='2' align='right'> </td>"
                    + "</tr></table>";
            //_html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
            _html += "<div><div style='text-align: center'>"
                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr><td colspan='4'><b>Details of Proposer</b></td></tr></table>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                      + "<tr>"
                     + "<td width='50%' align='left'>Email Address</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"



                     + "<tr>"
                     + "<td width='50%' align='left'>Gender</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     //+ "<tr>"
                //+ "<td width='50%' align='left'>Name of employer</td>"
                //+ "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                //+ "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     //+ "<tr>"
                //+ "<td width='50%' align='left'>NRIC Number</td>"
                //+ "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                //+ "</tr>"


                     + "<tr>"
                     + "<td width='50%' align='left'>Office No</td>"
                     + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Mobile No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                    + "<td width='50%' align='left'>Residential No</td>"
                    + "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                    + "</tr>"

                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2' align='left'></td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'>";

            //TRAVEL DETAILS
            _html += "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                   + "<tr><td colspan='4' align='left'><b>Travel Details </b></td></tr>"
                   + "<tr><td style='width:25%' align='left'>Area/Country of Destination</td>"
                   + "<td style='width: 25%' align='left'>" + _countryarea + "</td>"
                   + "<td style='width: 25%' align='left'>Trip Type</td>"
                   + "<td style='width: 25%' align='left'>" + GetTripType(_triptype) + "</td></tr>";

            string periodofinsurance = "";
            if (_triptype == "S")
            {
                periodofinsurance = _startdate.ToString("dd-MMM-yyyy") + " to " + _enddate.ToString("dd-MMM-yyyy");
            }
            else
            {
                periodofinsurance = "(start from) " + _startdate.ToString("dd-MMM-yyyy");
            }

            _html += "<tr><td style='width: 25%' align='left' >No of Travellers</td>"
                  + "<td align='left' colspan='3'>" + _nooftravellers + "</td></tr>"
                  + "<tr><td style='width:25%' align='left'>Period of Insurance</td>"
                  + "<td align='left' colspan='3'>" + periodofinsurance + "</td></tr>"
                  + "<tr><td colspan='4' align='left'> " + " " + "</td></tr>";


            _html += "<tr><td colspan='4' align='left'><b>Travellers to Insure</b></td></tr>";
            string InsuredHTML = "";
            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                for (int j = 0; j < _dsProposal.Tables[1].Rows.Count; j++)
                {
                    //if (_plantype == "Individual + Child")
                    if (_noofadults == "1" && _plantype == "Family" )
                    {
                        if (j == 0)
                        {
                            _insname = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _insnric = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _insdate = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _insdob = _insdate.Day.ToString("00") + "/" + _insdate.Month.ToString("00") + "/" + _insdate.Year.ToString("0000");
                            _insurergender = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _insname + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _insnric + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insdob + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _insurergender + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 1)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname1 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric1 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate1 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob1 = _childdate1.Day.ToString("00") + "/" + _childdate1.Month.ToString("00") + "/" + _childdate1.Year.ToString("0000");
                            _childgender1 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td colspan='4' align='left'><b>Child Details</b></td></tr>";
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>1. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname1 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric1 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob1 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender1 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 2)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname2 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric2 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate2 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob2 = _childdate2.Day.ToString("00") + "/" + _childdate2.Month.ToString("00") + "/" + _childdate2.Year.ToString("0000");
                            _childgender2 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>2. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname2 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric2 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob2 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender2 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 3)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname3 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric3 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate3 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob3 = _childdate3.Day.ToString("00") + "/" + _childdate3.Month.ToString("00") + "/" + _childdate3.Year.ToString("0000");
                            _childgender3 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>3. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname3 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric3 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob3 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender3 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 4)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname4 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric4 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate4 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob4 = _childdate4.Day.ToString("00") + "/" + _childdate4.Month.ToString("00") + "/" + _childdate4.Year.ToString("0000");
                            _childgender4 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>4. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname4 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric4 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob4 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender4 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 5)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname5 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric5 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate5 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob5 = _childdate5.Day.ToString("00") + "/" + _childdate5.Month.ToString("00") + "/" + _childdate5.Year.ToString("0000");
                            _childgender5 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>5. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname5 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric5 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob5 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender5 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 6)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname6 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric6 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate6 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob6 = _childdate6.Day.ToString("00") + "/" + _childdate6.Month.ToString("00") + "/" + _childdate6.Year.ToString("0000");
                            _childgender6 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>6. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname6 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric6 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob6 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender6 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                    }
                    else
                    {
                        if (j == 0)
                        {
                            _insname = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _insnric = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _insdate = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _insdob = _insdate.Day.ToString("00") + "/" + _insdate.Month.ToString("00") + "/" + _insdate.Year.ToString("0000");
                            _insurergender = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _insname + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _insnric + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insdob + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _insurergender + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 1)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 2).ToString();
                            _spousestatus = "Yes";
                            _sponame = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _sponric = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _spodate = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _spodob = _spodate.Day.ToString("00") + "/" + _spodate.Month.ToString("00") + "/" + _spodate.Year.ToString("0000");
                            _spousegender = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td colspan='4' align='left'><b>Spouse Details</b></td></tr>";
                            //InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
                            //           + "<td colspan='3' align='left' >" + _insname + "</td></tr>"
                            //            + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _sponame + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _sponric + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _spodob + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _spousegender + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 2)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname1 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric1 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate1 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob1 = _childdate1.Day.ToString("00") + "/" + _childdate1.Month.ToString("00") + "/" + _childdate1.Year.ToString("0000");
                            _childgender1 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td colspan='4' align='left'><b>Child Details</b></td></tr>";
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>1. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname1 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric1 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob1 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender1 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 3)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname2 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric2 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate2 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob2 = _childdate2.Day.ToString("00") + "/" + _childdate2.Month.ToString("00") + "/" + _childdate2.Year.ToString("0000");
                            _childgender2 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>2. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname2 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric2 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob2 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender2 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 4)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname3 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric3 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate3 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob3 = _childdate3.Day.ToString("00") + "/" + _childdate3.Month.ToString("00") + "/" + _childdate3.Year.ToString("0000");
                            _childgender3 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>3. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname3 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric3 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob3 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender3 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 5)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname4 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric4 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate4 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob4 = _childdate4.Day.ToString("00") + "/" + _childdate4.Month.ToString("00") + "/" + _childdate4.Year.ToString("0000");
                            _childgender4 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>4. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname4 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric4 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob4 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender4 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 6)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname5 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric5 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate5 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob5 = _childdate5.Day.ToString("00") + "/" + _childdate5.Month.ToString("00") + "/" + _childdate5.Year.ToString("0000");
                            _childgender5 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>5. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname5 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric5 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob5 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender5 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                        if (j == 7)
                        {
                            _noofchilds = (_dsProposal.Tables[1].Rows.Count - 1).ToString();
                            _spousestatus = "No";
                            _childname6 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric6 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childdate6 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob6 = _childdate6.Day.ToString("00") + "/" + _childdate6.Month.ToString("00") + "/" + _childdate6.Year.ToString("0000");
                            _childgender6 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();

                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>6. Child Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname6 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC/Passport Num</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric6 + "</td></tr>"
                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob6 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender6 + "</td></tr>";
                            //+ "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
                            //+ "<td colspan='3' align='left'>" + _insnric + "</td></tr>";
                        }
                    }
                    
                }
                InsuredHTML += "<tr><td align='left' colspan='4'>&nbsp; </td></tr>";
            }

            ////TRAVELLERS TO INSURE
            ////if (_dsProposal.Tables[1].Rows.Count > 0)
            ////{
            //int Insured = _dsProposal.Tables[1].Rows.Count;
            //string _fullname = "";
            //DateTime _insdob = CE.Global.General.GetUTCDateTime();
            //string _nricpassport = "";
            //string InsuredHTML = "";

            //_html += "<tr><td colspan='4' align='left'><b>Travellers to Insure</b></td></tr>";

            //for (int i = 0; i < Insured; i++)
            //{
            //    _fullname = _dsProposal.Tables[1].Rows[i]["FullName"].ToString();
            //    _nricpassport = _dsProposal.Tables[1].Rows[i]["IdentificationNum"].ToString();

            //    if (_dsProposal.Tables[1].Rows[i]["Birthday"].ToString() != "")
            //        _insdob = Convert.ToDateTime(_dsProposal.Tables[1].Rows[i]["Birthday"].ToString());

            //    string _insDD = _insdob.Day.ToString("00");
            //    string _insMM = _insdob.Month.ToString("00");
            //    string _insYY = _insdob.Year.ToString();


            //    string _insbirth = _insDD + "/" + _insMM + "/" + _insYY.ToString();

            //    InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
            //               + "<td colspan='3' align='left' >" + _fullname + "</td></tr>"
            //                + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
            //                + "<td colspan='3' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insbirth + "</td></tr>"
            //                + "<tr><td style='width: 25%' align='left'>NRIC/Passport Num</td>"
            //                + "<td colspan='3' align='left'>" + _nricpassport + "</td></tr>";


            //}
            //InsuredHTML += "<tr><td align='left' colspan='4'>&nbsp; </td></tr>";

            _html += InsuredHTML;

            //}

            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetTIDownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
                  + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                  + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                  + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                  + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                  + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                  + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                  + "<td style='width: 25%' align='left'>Card expiry date</td>"
                  + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                  + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                  + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                  + "<td style='width: 25%' align='left'></td>"
                  + "<td style='width: 25%' align='left'></td></tr>"

                  + "</table>"
                  + "</td>"
                  + "</tr>"

                  + "</table>"
                  + "</div></div>";
            }
            else
            {
                _html += " "

                  + "</table>"
                  + "</td>"
                  + "</tr>"

                  + "</table>"
                  + "</div></div>";
            }

        }
        return _html;
    }

    public string GenerateTIHTML_Liberty(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetLibertyProposal(RefId, InsuranceType);
        string _html = "";
        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            string _name, _dob, _nationality, _nric, _mobile, _hoemphone, _officephone, _faxno, _unitno, _homeno, _address;
            string _postalcode, _empname, _email, _dd, _mm, _yy;
            string _plantype, _triptype, _countryarea, _nooftravellers, _totalpremium;
            string _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _planname;
            string _sex, _maritalstatus, _occupation;
            DateTime _dofb = CE.Global.General.GetUTCDateTime(), _startdate, _enddate;
            string quoteref = General.GetRefNumber(RefId);

            _name = ""; _dob = ""; _nationality = ""; _nric = ""; _mobile = ""; _hoemphone = ""; _officephone = "";
            _faxno = ""; _unitno = ""; _homeno = ""; _address = ""; _postalcode = ""; _empname = ""; _email = "";
            _dd = ""; _mm = ""; _yy = ""; _plantype = ""; _triptype = ""; _countryarea = ""; _nooftravellers = ""; _totalpremium = "";
            _nameofcard = ""; _issuebank = ""; _ccno = ""; _cno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = ""; _planname = "";
            _sex = ""; _maritalstatus = ""; _occupation = "";


            string _insname, _insdob, _insnric, _insgender, _insoccupation,_insnation, _insrelation;
            string _sponame, _spodob, _sponric, _spogender,_spooccupation,_sponation, _sporelation;
            string _childname1, _childdob1, _childnric1, _childgender1, _childnation1, _childrelation1;
            string _childname2, _childdob2, _childnric2, _childgender2, _childnation2, _childrelation2;
            string _childname3, _childdob3, _childnric3, _childgender3, _childnation3, _childrelation3;
            string _childname4, _childdob4, _childnric4, _childgender4, _childnation4, _childrelation4;
            string _childname5, _childdob5, _childnric5, _childgender5, _childnation5, _childrelation5;
            string _childname6, _childdob6, _childnric6, _childgender6, _childnation6, _childrelation6;
            string _noofadults, _noofchilds;

            _insname = ""; _insdob = ""; _insnric = ""; _insgender = ""; _insoccupation = ""; _insnation = ""; _insrelation = "";
            _sponame = ""; _spodob = ""; _sponric = ""; _spogender = ""; _spooccupation = ""; _sponation = ""; _sporelation = "";
            _childname1 = ""; _childdob1 = ""; _childnric1 = ""; _childgender1 = ""; _childnation1 = ""; _childrelation1 = "";
            _childname2 = ""; _childdob2 = ""; _childnric2 = ""; _childgender2 = ""; _childnation2 = ""; _childrelation2 = "";
            _childname3 = ""; _childdob3 = ""; _childnric3 = ""; _childgender3 = ""; _childnation3 = ""; _childrelation3 = "";
            _childname4 = ""; _childdob4 = ""; _childnric4 = ""; _childgender4 = ""; _childnation4 = ""; _childrelation4 = "";
            _childname5 = ""; _childdob5 = ""; _childnric5 = ""; _childgender5 = ""; _childnation5 = ""; _childrelation5 = "";
            _childname6 = ""; _childdob6 = ""; _childnric6 = ""; _childgender6 = ""; _childnation6 = ""; _childrelation6 = "";
            _noofadults = "0"; _noofchilds = "0";


            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["DOB"].ToString() != "")
            {
                _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());

                _dd = _dofb.Day.ToString("00");
                _mm = _dofb.Month.ToString("00");
                _yy = _dofb.Year.ToString().Substring(2, 2);

                _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            }


            _empname = _dsProposal.Tables[0].Rows[0]["EmpName"].ToString();
            //_email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _sex = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["MaritalStatus"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Occupation"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _plantype = _dsProposal.Tables[0].Rows[0]["PlanType"].ToString();

            float fpremium = float.Parse(_dsProposal.Tables[0].Rows[0]["TotalPremium"].ToString());
            _totalpremium = String.Format("{0:C}", fpremium);

            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _faxno = _dsProposal.Tables[0].Rows[0]["FaxNo"].ToString();

            _triptype = _dsProposal.Tables[0].Rows[0]["TripType"].ToString();
            _countryarea = _dsProposal.Tables[0].Rows[0]["Country"].ToString();
            _nooftravellers = _dsProposal.Tables[0].Rows[0]["NoOfTravellers"].ToString();
            _startdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _enddate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _noofadults = _dsProposal.Tables[0].Rows[0]["NoOfAdults"].ToString();
            _noofchilds = _dsProposal.Tables[0].Rows[0]["NoofChilds"].ToString();

            //_nameofcard = _dsProposal.Tables[0].Rows[0]["NameoftheCard"].ToString();
            //_issuebank = _dsProposal.Tables[0].Rows[0]["IssuingBankName"].ToString();
            //_cno = _dsProposal.Tables[0].Rows[0]["CreditCardNo"].ToString();
            //_ccexmm = _dsProposal.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
            //_ccexyy = _dsProposal.Tables[0].Rows[0]["CardExpiryYear"].ToString();
            //_cctype = _dsProposal.Tables[0].Rows[0]["CardType"].ToString();
            //_ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);

            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 29, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            Int32 iPromo = GetTravelPromoDiscount("29");

            if (iPromo > 0)
            {
                _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + " (" + _plantype + ")</td>"
                        + "<td colspan='2' align='right'><b>Total Premium</b> (w/GST) : " + _totalpremium.ToString() + "</td>"
                        + "<tr><td width='25%'><b>Quote Reference</b></td><td>TIL" + quoteref + "</td>"
                        + "<td colspan='2' align='right'><b>w/ " + iPromo.ToString() + "% discount</b></td>"
                        + "</tr></table>";
            }
            else
            {
                _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + " (" + _plantype + ")</td>"
                        + "<td colspan='2' align='right'><b>Total Premium</b> (w/GST) : " + _totalpremium.ToString() + "</td>"
                        + "<tr><td width='25%'><b>Quote Reference</b></td><td>TIL" + quoteref + "</td>"
                        + "<td colspan='2' align='right'> </td>"
                        + "</tr></table>";
            }

            //_html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
            _html += "<div><div style='text-align: center'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                    + "<tr><td colspan='4'><b>Details of Proposer</b></td></tr></table>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                    + "<tr>"
                    + "<td width='50%'>" //Start 1
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                    + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td align='left'>Address</td>"
                    + "<td align='left'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                    + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                    + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                    + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                    + "</table>"
                    + "</td>"
                    + "</tr>"

                     + "<tr>"
                    + "<td width='50%' align='left'>Sex</td>"
                    + "<td width='50%' align='left'>" + _sex.ToString() + "</td>"
                    + "</tr>"

                     + "<tr>"
                    + "<td width='50%' align='left'>Marital Status</td>"
                    + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                    + "</tr>"


                     + "<tr>"
                    + "<td width='50%' align='left'>Occupation</td>"
                    + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                    + "</tr>"

                    //+ "<tr>"
                //+ "<td width='50%' align='left'>Name of employer</td>"
                //+ "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                //+ "</tr>"

                    + "</table>"
                    + "</td>" //End 1

                    + "<td width='50%'>" //Start 2
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Date of Birth</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Nationality</td>"
                    + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>NRIC Number</td>"
                    + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                    + "</tr>"


                    + "<tr>"
                    + "<td width='50%' align='left'>Office No</td>"
                    + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Mobile No</td>"
                    + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                   + "<td width='50%' align='left'>Residential No</td>"
                   + "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                   + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Email Address </td>"
                    + "<td width='50%' align='left'>" + _email.ToString() + " </td>"
                    + "</tr>"

                    + "</table>"
                    + "</td>" //End 2
                    + "</tr>"

                    + "<tr>"
                    + "<td colspan='2' align='left'></td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td colspan='2'>";

            //TRAVEL DETAILS
            _html += "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                   + "<tr><td colspan='4' align='left'><b>Travel Details </b></td></tr>"
                   + "<tr><td style='width:25%' align='left'>Area/Country of Destination</td>"
                   + "<td style='width: 25%' align='left'>" + _countryarea + "</td>"
                   + "<td style='width: 25%' align='left'>Trip Type</td>"
                   + "<td style='width: 25%' align='left'>" + GetTripType(_triptype) + "</td></tr>";

            string periodofinsurance = "";
            if (_triptype == "S")
            {
                periodofinsurance = _startdate.ToString("dd-MMM-yyyy") + " to " + _enddate.ToString("dd-MMM-yyyy");
            }
            else
            {
                periodofinsurance = "(start from) " + _startdate.ToString("dd-MMM-yyyy");
            }

            _html += "<tr><td style='width: 25%' align='left' >No of Travellers</td>"
                  + "<td align='left' colspan='3'>" + _nooftravellers + "</td></tr>"
                  + "<tr><td style='width:25%' align='left'>Period of Insurance</td>"
                  + "<td align='left' colspan='3'>" + periodofinsurance + "</td></tr>"
                  + "<tr><td colspan='4' align='left'> " + " " + "</td></tr>";

            //Travelers to Insure
            _html += "<tr><td colspan='4' align='left'><b>Travellers to Insure</b></td></tr>";
            string InsuredHTML = "";
            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                for (int j = 0; j < _dsProposal.Tables[1].Rows.Count; j++)
                {
                    if (j == 0)
                    {
                        _insname = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                        _insnric = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                        DateTime _insdate = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                        _insdob = _insdate.Day.ToString("00") + "/" + _insdate.Month.ToString("00") + "/" + _insdate.Year.ToString("0000");
                        _insgender = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                        _insoccupation = _dsProposal.Tables[2].Rows[j]["Occupation"].ToString();
                        _insrelation = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                        _insnation = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                        InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Full Name</td>"
                                   + "<td  width='25%' align='left' >" + _insname + "</td>"
                                   + "<td style='width:25%' align='left'>NRIC No.</td>"
                                   + "<td  style='width:25%' align='left'>" + _insnric + "</td></tr>"

                                    + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                    + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insdob + "</td>"
                                    + "<td style='width:25%' align='left'>Gender</td>"
                                    + "<td style='width:25%' align='left'>" + _insgender + "</td></tr>"

                                    + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                    + "<td style='width:25%' align='left'>" + _insnation + "</td>"
                                    + "<td style='width:25%' align='left'>Relation</td>"
                                    + "<td style='width:25%' align='left'>" + _insrelation + "</td></tr>"

                                    + "<tr><td style='width:25%' align='left'>Occupation</td>"
                                    + "<td style='width:25%' align='left'>" + _insoccupation + "</td>"
                                    + "<td style='width:25%' align='left'></td>"
                                    + "<td style='width:25%' align='left'></td></tr>"

                                    +"<tr><td colspan='4' align='left'></td></tr>";

                    }
                    if (Convert.ToInt32(_noofadults) > 1)
                    {
                        if (j == 1)
                        {
                            _sponame = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _sponric = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _spodate = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _spodob = _spodate.Day.ToString("00") + "/" + _spodate.Month.ToString("00") + "/" + _spodate.Year.ToString("0000");
                            _spogender = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _spooccupation = _dsProposal.Tables[2].Rows[j]["Occupation"].ToString();
                            _sporelation = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _sponation = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>Adult2 (or) Spouse Full Name</td>"
                                       + "<td  width='25%' align='left' >" + _sponame + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _sponric + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _spodob + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _spogender + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _sponation + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _sporelation + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Occupation</td>"
                                        + "<td style='width:25%' align='left'>" + _spooccupation + "</td>"
                                        + "<td style='width:25%' align='left'></td>"
                                        + "<td style='width:25%' align='left'></td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 2)
                        {
                            InsuredHTML = InsuredHTML + "<tr><td colspan='4' align='left'><b>Child Details</b></td></tr>";
                            _childname1 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric1 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate1 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob1 = _childate1.Day.ToString("00") + "/" + _childate1.Month.ToString("00") + "/" + _childate1.Year.ToString("0000");
                            _childgender1 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation1 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation1 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>1. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname1 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric1 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob1 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender1 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation1 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation1 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 3)
                        {
                           _childname2 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric2 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate2 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob2 = _childate2.Day.ToString("00") + "/" + _childate2.Month.ToString("00") + "/" + _childate2.Year.ToString("0000");
                            _childgender2 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation2 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation2 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>2. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname2 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric2 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob2 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender2 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation2 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation2 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 4)
                        {
                            _childname3 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric3 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate3 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob3 = _childate3.Day.ToString("00") + "/" + _childate3.Month.ToString("00") + "/" + _childate3.Year.ToString("0000");
                            _childgender3 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation3 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation3 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>3. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname3 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric3 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob3 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender3 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation3 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation3 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 5)
                        {
                            _childname4 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric4 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate4 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob4 = _childate4.Day.ToString("00") + "/" + _childate4.Month.ToString("00") + "/" + _childate4.Year.ToString("0000");
                            _childgender4 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation4 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation4 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>4. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname4 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric4 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob4 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender4 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation4 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation4 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 6)
                        {
                            _childname5 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric5 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate5 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob5 = _childate5.Day.ToString("00") + "/" + _childate5.Month.ToString("00") + "/" + _childate5.Year.ToString("0000");
                            _childgender5 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation5 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation5 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>5. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname5 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric5 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob5 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender5 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation5 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation5 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 7)
                        {
                            _childname6 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric6 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate6 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob6 = _childate6.Day.ToString("00") + "/" + _childate6.Month.ToString("00") + "/" + _childate6.Year.ToString("0000");
                            _childgender6 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation6 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation6 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>6. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname6 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric6 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob6 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender6 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation6 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation6 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                    }
                    else
                    {
                        if (j == 1)
                        {
                            InsuredHTML = InsuredHTML + "<tr><td colspan='4' align='left'><b>Child Details</b></td></tr>";
                            _childname1 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric1 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate1 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob1 = _childate1.Day.ToString("00") + "/" + _childate1.Month.ToString("00") + "/" + _childate1.Year.ToString("0000");
                            _childgender1 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation1 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation1 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>1. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname1 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric1 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob1 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender1 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation1 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation1 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 2)
                        {
                            _childname2 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric2 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate2 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob2 = _childate2.Day.ToString("00") + "/" + _childate2.Month.ToString("00") + "/" + _childate2.Year.ToString("0000");
                            _childgender2 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation2 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation2 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>2. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname2 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric2 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob2 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender2 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation2 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation2 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 3)
                        {
                            _childname3 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric3 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate3 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob3 = _childate3.Day.ToString("00") + "/" + _childate3.Month.ToString("00") + "/" + _childate3.Year.ToString("0000");
                            _childgender3 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation3 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation3 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>3. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname3 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric3 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob3 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender3 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation3 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation3 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 4)
                        {
                            _childname4 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric4 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate4 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob4 = _childate4.Day.ToString("00") + "/" + _childate4.Month.ToString("00") + "/" + _childate4.Year.ToString("0000");
                            _childgender4 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation4 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation4 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>4. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname4 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric4 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob4 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender4 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation4 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation4 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 5)
                        {
                            _childname5 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric5 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate5 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob5 = _childate5.Day.ToString("00") + "/" + _childate5.Month.ToString("00") + "/" + _childate5.Year.ToString("0000");
                            _childgender5 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation5 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation5 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>5. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname5 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric5 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob5 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender5 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation5 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation5 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                        if (j == 6)
                        {
                            _childname6 = _dsProposal.Tables[1].Rows[j]["FullName"].ToString();
                            _childnric6 = _dsProposal.Tables[1].Rows[j]["IdentificationNum"].ToString();
                            DateTime _childate6 = Convert.ToDateTime(_dsProposal.Tables[1].Rows[j]["Birthday"].ToString());
                            _childdob6 = _childate6.Day.ToString("00") + "/" + _childate6.Month.ToString("00") + "/" + _childate6.Year.ToString("0000");
                            _childgender6 = _dsProposal.Tables[1].Rows[j]["Gender"].ToString();
                            _childrelation6 = _dsProposal.Tables[1].Rows[j]["RelationshipToProposer"].ToString();
                            _childnation6 = _dsProposal.Tables[1].Rows[j]["Nationality"].ToString();
                            InsuredHTML = InsuredHTML + "<tr><td style='width:25%' align='left'>6. Child Name</td>"
                                       + "<td  width='25%' align='left' >" + _childname6 + "</td>"
                                       + "<td style='width:25%' align='left'>NRIC No.</td>"
                                       + "<td  style='width:25%' align='left'>" + _childnric6 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Date of Birth</td>"
                                        + "<td style='width:25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob6 + "</td>"
                                        + "<td style='width:25%' align='left'>Gender</td>"
                                        + "<td style='width:25%' align='left'>" + _childgender6 + "</td></tr>"

                                        + "<tr><td style='width:25%' align='left'>Nationality</td>"
                                        + "<td style='width:25%' align='left'>" + _childnation6 + "</td>"
                                        + "<td style='width:25%' align='left'>Relation</td>"
                                        + "<td style='width:25%' align='left'>" + _childrelation6 + "</td></tr>"

                                        + "<tr><td colspan='4' align='left'></td></tr>";
                        }
                    }
                }
            }
            _html = _html + InsuredHTML;
            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetTIDownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
                + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Card expiry date</td>"
                + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                + "<td style='width: 25%' align='left'></td>"
                + "<td style='width: 25%' align='left'></td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";
            }
            else
            {
                _html += " "

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";
            }
        }
        return _html;
    }

    public string GeneratePAHTML_Hsbc(Int64 RefId, string InsuranceType)
    {
        string _html = "";
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetHSBCProposal(RefId, InsuranceType);

        if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
        {
            #region variables
            string _name, _dob, _nationality, _nric, _maritalstatus, _mobile, _hoemphone, _officephone, _postalcode, _unitno, _homeno, _address;
            string _gender, _sprstatus, _email, _covertype, _noofchild, _engagedtype, _insstartdate, _insenddate, _planname, _annualpremium;
            string _spousename, _spousenric, _spousedob, _spousenationality, _spouseoccupation, _eligible, _engagedoccup;
            string _nameofcard, _issuebank, _cno, _ccexmm, _ccexyy, _cctype, _ccno, _occupation, _painsid, _covertypename, _divspousstatus;
            _spousename = ""; _spousenric = ""; _spousedob = ""; _spousenationality = ""; _spouseoccupation = "";
            _eligible = ""; _engagedoccup = ""; _engagedtype = ""; _cctype = ""; _covertypename = "";
            _nameofcard = ""; _issuebank = ""; _cno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            #endregion

            #region Assign Values
            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _sprstatus = _dsProposal.Tables[0].Rows[0]["SPRPRStatus"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _hoemphone = _dsProposal.Tables[0].Rows[0]["HomePhoneNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _eligible = _dsProposal.Tables[0].Rows[0]["ElgibleAge"].ToString();
            _engagedoccup = _dsProposal.Tables[0].Rows[0]["EngagedOccupation"].ToString();
            //if (_engagedoccup == "True")
            //{
            //    _engagedtype = "I/my Spouse am/are engaged in the following occupations and we would like to apply for restricted coverage";
            //}
            //else
            //{
            //    _engagedtype = "";
            //}
            _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
            _painsid = _dsProposal.Tables[0].Rows[0]["PAInsId"].ToString();

            _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _spousename = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                _spousenric = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                _spousedob = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                _spousenationality = _dsProposal.Tables[1].Rows[0]["SpouseNationality"].ToString();
                _spouseoccupation = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                _divspousstatus = "block";
            }
            else
            {
                _divspousstatus = "none";
            }
            if (_covertype == "IND")
            {
                _covertypename = "Individual";
            }
            else if (_covertype == "INDSP")
            {
                _covertypename = "Individual & Spouse";
            }
            else if (_covertype == "INDCHD")
            {
                _covertypename = "Individual & Children";
            }
            else if (_covertype == "INDSPCHD")
            {
                _covertypename = "Individual, Spouse & Children";
            }

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            _ccno = "";
            //_nameofcard = _dsProposal.Tables[0].Rows[0]["NameoftheCard"].ToString();
            //_issuebank = _dsProposal.Tables[0].Rows[0]["IssuingBankName"].ToString();
            //_cno = _dsProposal.Tables[0].Rows[0]["CreditCardNo"].ToString();
            //_ccexmm = _dsProposal.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
            //_ccexyy = _dsProposal.Tables[0].Rows[0]["CardExpiryYear"].ToString();
            //_cctype = _dsProposal.Tables[0].Rows[0]["CardType"].ToString();
            //_ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);


            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 23, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            #endregion

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr>";
            _html += "<tr><td width='25%'><b>Policy Type</b></td><td>" + _covertypename + "</td><td colspan='2' align='right'></td></tr></table>";
            _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left'>Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Occupation / Nature of Business</td>"
                     + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Mobile No</td>"
                     + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Email</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Insurance Start Date</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Date of Birth</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Nationality</td>"
                     + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>NRIC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Gender</td>"
                     + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Marital Status</td>"
                     + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Office No</td>"
                     + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Residential No</td>"
                     + "<td width='50%' align='left'>" + _hoemphone.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Insurance End Date</td>"
                     + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>";

            //if (_engagedoccup == "True")
            //{
            //    _html += "<tr>"
            //    + "<td colspan='2'>" + _engagedtype.ToString() + "</td>"
            //    + "</tr>";
            //}
            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr>"
                + "<td colspan='4' align='left'><b>Spouse Details</b></td>"
                + "</tr>"

                + "<tr><td style='width:25%' align='left'>Spouse Name</td>"
                + "<td style='width: 25%' align='left'>" + _spousename.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse Nationality</td>"
                + "<td style='width: 25%' align='left'>" + _spousenationality.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Spouse NRIC No.</td>"
                + "<td style='width: 25%' align='left'>" + _spousenric.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse DOB</td>"
                + "<td style='width: 25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _spousedob.ToString() + "</td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>";
            }

            _html += "<tr>"
                 + "<td colspan='2'>Number of Children : " + _noofchild.ToString() + "</td>"
                 + "</tr>"

                 + "<tr>"
                 + "<td colspan='2'>"
                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>";

            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetPADownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
                + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Card expiry date</td>"
                + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                + "<td style='width: 25%' align='left'></td>"
                + "<td style='width: 25%' align='left'></td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";
            }
            else
            {
                _html += " "

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";

            }


            //+ "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
            //+ "<tr><td style='width:25%' align='left'>Name of the Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Issuing Bank</td>"
            //+ "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
            //+ "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Card expiry date</td>"
            //+ "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Type of Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'></td>"
            //+ "<td style='width: 25%' align='left'></td></tr>"

            //+ "</table>"
            //+ "</td>"
            //+ "</tr>"

            //+ "</table>"
            //+ "</div></div>";
        }
        return _html;
    }

    public string GeneratePAHTML_Liberty(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetLibertyProposal(RefId, InsuranceType);
        string _html = "";
        int l = _dsProposal.Tables.Count;
        if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
        {
            #region variables
            string _name, _dob, _gender, _email, _nationality, _nric, _mobile, _officephone, _postalcode, _unitno, _homeno, _address, _noofchild;
            string _spousename, _spousegender, _spousenric, _spousedob, _spousenationality, _spouseoccupation, _spouserelation, _comroc;
            string _occupfallstatus, _occupfallreason, _engagedsportsstatus, _enagedsportsreason, _otherinsstatus, _otherinscom, _otherinsdetail;
            string _physicalstatus, _physicalreason, _anyclaims, _anyclaimreason, _inscancel, _inscancelreason, _insstartdate, _insenddate, _planname, _annualpremium, _natureofbusi;
            string _nameofcard, _issuebank, _cno, _ccexmm, _ccexyy, _cctype, _ccno, _occupation, _painsid, _covertype, _covertypename, _divspousstatus, _producerCode;

            _spousename = ""; _spousenric = ""; _spousedob = ""; _spousenationality = ""; _spouseoccupation = ""; _spouserelation = "";
            _cctype = ""; _covertypename = ""; _otherinscom = ""; _nameofcard = ""; _issuebank = ""; _cno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            _producerCode = "D9999-TD";
            #endregion

            #region Assign Values
            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _natureofbusi = _dsProposal.Tables[0].Rows[0]["NatBusi"].ToString();
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _comroc = _dsProposal.Tables[0].Rows[0]["CompanyROCNo"].ToString();
            _painsid = _dsProposal.Tables[0].Rows[0]["PAInsId"].ToString();
            _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
            _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
            int _childcount = Convert.ToInt32(_noofchild);
            string[] _childname = new string[_childcount];
            string[] _childdob = new string[_childcount];
            string[] _childnationality = new string[_childcount];
            string[] _childnric = new string[_childcount];
            string[] _childrelation = new string[_childcount];
            string[] _childgender = new string[_childcount];
            if (_childcount > 0)
            {

                for (int i = 0; i < _childcount; i++)
                {
                    if (_covertype == "INDSPCHD")
                    {
                        _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                        _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                        _childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                        _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                        _childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                        _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                    }
                    else if (_covertype == "INDCHD")
                    {
                        _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                        _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                        _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                        _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                        _childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                        _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                    }
                }
            }


            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _spousename = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                _spousenric = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                _spousedob = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                _spousenationality = _dsProposal.Tables[1].Rows[0]["SpouseNationality"].ToString();
                _spouseoccupation = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                _spouserelation = _dsProposal.Tables[1].Rows[0]["SpouseRelation"].ToString();
                _spousegender = _dsProposal.Tables[1].Rows[0]["Gender"].ToString();
                _divspousstatus = "block";
            }
            else
            {
                _divspousstatus = "none";
            }
            if (_covertype == "IND")
            {
                _covertypename = "Individual";
            }
            else if (_covertype == "INDSP")
            {
                _covertypename = "Individual & Spouse";
            }
            else if (_covertype == "INDCHD")
            {
                _covertypename = "Individual & Children";
            }
            else if (_covertype == "INDSPCHD")
            {
                _covertypename = "Individual, Spouse & Children";
            }

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["HasOccupationFall"].ToString() == "True")
            {
                _occupfallstatus = "Yes";
                _occupfallreason = _dsProposal.Tables[0].Rows[0]["OccupationFall"].ToString();
            }
            else
            {
                _occupfallstatus = "No";
                _occupfallreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasEngagedSportsActivities"].ToString() == "True")
            {
                _engagedsportsstatus = "Yes";
                _enagedsportsreason = _dsProposal.Tables[0].Rows[0]["EngagedSportsActivities"].ToString();
            }
            else
            {
                _engagedsportsstatus = "No";
                _enagedsportsreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalDefects"].ToString() == "True")
            {
                _physicalstatus = "Yes";
                _physicalreason = _dsProposal.Tables[0].Rows[0]["PhysicalDefects"].ToString();
            }
            else
            {
                _physicalstatus = "No";
                _physicalreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasOtherInsurance"].ToString() == "True")
            {
                _otherinsstatus = "Yes";
                if (_otherinsstatus == "Yes")
                {
                    if (_covertype == "INDSPCHD")
                    {
                        _otherinscom = _dsProposal.Tables[3].Rows[0]["CompanyName"].ToString();
                    }
                    else if (_covertype == "INDSP" || _covertype == "INDCHD")
                    {
                        _otherinscom = _dsProposal.Tables[2].Rows[0]["CompanyName"].ToString();
                    }
                    else if (_covertype == "IND")
                    {
                        _otherinscom = _dsProposal.Tables[1].Rows[0]["CompanyName"].ToString();
                    }
                }
                _otherinsdetail = _dsProposal.Tables[0].Rows[0]["OtherInsuranceDetails"].ToString();
            }
            else
            {
                _otherinsstatus = "No";
                _otherinscom = "";
                _otherinsdetail = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasAnyClaimsfromInsurer"].ToString() == "True")
            {
                _anyclaims = "Yes";
                _anyclaimreason = _dsProposal.Tables[0].Rows[0]["AnyClaimsfromInsurer"].ToString();
            }
            else
            {
                _anyclaims = "No";
                _anyclaimreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceCancelled"].ToString() == "True")
            {
                _inscancel = "Yes";
                _inscancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceCancelledDetails"].ToString();
            }
            else
            {
                _inscancel = "No";
                _inscancelreason = "";
            }

            _ccno = "";
            //_nameofcard = _dsProposal.Tables[0].Rows[0]["NameoftheCard"].ToString();
            //_issuebank = _dsProposal.Tables[0].Rows[0]["IssuingBankName"].ToString();
            //_cno = _dsProposal.Tables[0].Rows[0]["CreditCardNo"].ToString();
            //_ccexmm = _dsProposal.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
            //_ccexyy = _dsProposal.Tables[0].Rows[0]["CardExpiryYear"].ToString();
            //_cctype = _dsProposal.Tables[0].Rows[0]["CardType"].ToString();
            //_ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);


            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 29, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            #endregion

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr>";
            _html += "<tr><td width='25%'><b>Policy Type</b></td><td>" + _covertypename + "</td><td colspan='2' align='right'></td></tr></table>";
            _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                    + "<tr>"
                    + "<td width='50%'>" //Start 1
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                    + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                    + "</tr>"

                     + "<tr>"
                    + "<td width='50%' align='left'>Producer Code</td>"
                    + "<td width='50%' align='left'>" + _producerCode.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td align='left'>Address</td>"
                    + "<td align='left'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                    + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                    + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                    + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                    + "</table>"
                    + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Occupation</td>"
                    + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Mobile No</td>"
                    + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Email</td>"
                    + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Insurance Start Date</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
                    + "</tr>"

                    + "</table>"
                    + "</td>" //End 1

                    + "<td width='50%'>" //Start 2
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Date of Birth</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Nationality</td>"
                    + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>NRIC Number</td>"
                    + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Gender</td>"
                    + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Nature of Business</td>"
                    + "<td width='50%' align='left'>" + _natureofbusi.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Office No</td>"
                    + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Company ROC No.</td>"
                    + "<td width='50%' align='left'>" + _comroc.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Insurance End Date</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td>"
                    + "</tr>"

                    + "</table>"
                    + "</td>" //End 2
                    + "</tr>";

            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr>"
                + "<td colspan='4' align='left'><b>Spouse Details</b></td>"
                + "</tr>"

                + "<tr><td style='width:25%' align='left'>Spouse Name</td>"
                + "<td style='width: 25%' align='left'>" + _spousename.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse Nationality</td>"
                + "<td style='width: 25%' align='left'>" + _spousenationality.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Spouse NRIC No.</td>"
                + "<td style='width: 25%' align='left'>" + _spousenric.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse DOB</td>"
                + "<td style='width: 25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _spousedob.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Spouse Relation</td>"
                + "<td style='width: 25%' align='left'>" + _spouserelation.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _spouseoccupation.ToString() + "</td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>";
            }

            _html += "<tr>"
            + "<td colspan='2'>Number of Children : " + _noofchild.ToString() + "</td>"
            + "</tr>";
            if (_childcount > 0)
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr>"
                + "<td colspan='4' align='left'><b>Child Details</b></td>"
                + "</tr>";
                for (int j = 0; j < _childcount; j++)
                {
                    int sno = j + 1;
                    _html += "<tr>"
                    + "<td colspan='4' align='left'><b>Child " + sno.ToString() + "</b></td>"
                    + "</tr>"

                    + "<tr><td style='width:25%' align='left'>Name</td>"
                    + "<td style='width: 25%' align='left'>" + _childname[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Nationality</td>"
                    + "<td style='width: 25%' align='left'>" + _childnationality[j].ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>DOB</td>"
                    + "<td style='width: 25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>NRICNo</td>"
                    + "<td style='width: 25%' align='left'>" + _childnric[j].ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Gender</td>"
                    + "<td style='width: 25%' align='left'>" + _childgender[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Relation</td>"
                    + "<td style='width: 25%' align='left'>" + _childrelation[j].ToString() + "</td></tr>";

                }
                _html += "</table>"
                + "</td>"
                + "</tr>";
            }

            _html += "<tr>"
            + "<td colspan='2'>"
            + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

            + "<tr><td colspan='4' align='left'><b>Other Details</b></td></tr>"

            + "<tr><td colspan='3' align='left'>(a) Does your occupation fall within any of the Decline of referred Risks?</td>"
            + "<td style='width: 25%' align='left'>" + _occupfallstatus.ToString() + "</td></tr>";
            if (_occupfallstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _occupfallreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(b) Do you engage in any sports/activities which are excluded by the policy?</td>"
            + "<td style='width: 25%' align='left'>" + _engagedsportsstatus.ToString() + "</td></tr>";
            if (_engagedsportsstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _enagedsportsreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(c) Do you suffer from any disease, physical defect or infirmity?</td>"
            + "<td style='width: 25%' align='left'>" + _physicalstatus.ToString() + "</td></tr>";
            if (_physicalstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _physicalreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(d)Do you have any other personal accident insurance?</td>"
            + "<td style='width: 25%' align='left'>" + _otherinsstatus.ToString() + "</td></tr>";
            if (_otherinsstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Insurance Company</td>"
                + "<td colspan='3' align='left'>" + _otherinscom.ToString() + "</td></tr>"
                + "<tr><td style='width: 25%' align='left'>Details</td>"
                + "<td colspan='3' align='left'>" + _otherinsdetail.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(e) Have you ever made a claim against any insurer in respect of any bodily injury?</td>"
            + "<td style='width: 25%' align='left'>" + _anyclaims.ToString() + "</td></tr>";
            if (_anyclaims.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _anyclaimreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(f) Has Your application for life or accident insurance been declined or has any such insurance been cancelled or renewal refused or subject to special terms?</td>"
            + "<td style='width: 25%' align='left'>" + _inscancel.ToString() + "</td></tr>";
            if (_inscancel.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _inscancelreason.ToString() + "</td></tr>";
            }


            ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
            DataSet dsDownload = new DataSet();
            dsDownload = _proposaldb.GetPADownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

            string isdownloaded = "False";
            if (dsDownload.Tables[0].Rows.Count > 0)
            {
                isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
            }

            if (isdownloaded == "False")
            {
                _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
                   + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
                   + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
                   + "<td style='width: 25%' align='left'>Issuing Bank</td>"
                   + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

                   + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
                   + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
                   + "<td style='width: 25%' align='left'>Card expiry date</td>"
                   + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

                   + "<tr><td style='width:25%' align='left'>Type of Card</td>"
                   + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
                   + "<td style='width: 25%' align='left'></td>"
                   + "<td style='width: 25%' align='left'></td></tr>"

                   + "</table>"
                   + "</td>"
                   + "</tr>"

                   + "</table>"
                   + "</div></div>";
            }
            else
            {
                _html += " "

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";

            }
            // _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
            //+ "<tr><td style='width:25%' align='left'>Name of the Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Issuing Bank</td>"
            //+ "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
            //+ "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Card expiry date</td>"
            //+ "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

            //+ "<tr><td style='width:25%' align='left'>Type of Card</td>"
            //+ "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'></td>"
            //+ "<td style='width: 25%' align='left'></td></tr>"

            //+ "</table>"
            //+ "</td>"
            //+ "</tr>"

            //+ "</table>"
            //+ "</div></div>";


        }
        return _html;
    }

    public string GeneratePAHTML_Etiqa(Int64 RefId, string InsuranceType)
    {
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetEtiqaProposal(RefId, InsuranceType);
        string _html = "";
        int l = _dsProposal.Tables.Count;
        if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
        {
            #region variables
            string _name, _dob, _gender, _email, _nationality, _nric, _mobile, _officephone, _postalcode, _unitno, _homeno, _address, _noofchild;
            string _spousename, _spousegender, _spousenric, _spousedob, _spousenationality, _spouseoccupation, _spouserelation, _comroc;
            string _occupfallstatus, _occupfallreason, _engagedsportsstatus, _enagedsportsreason, _otherinsstatus, _otherinscom, _otherinsdetail;
            string _physicalstatus, _physicalreason, _anyclaims, _anyclaimreason, _inscancel, _inscancelreason, _insstartdate, _insenddate, _planname, _annualpremium, _natureofbusi;
            string _nameofcard, _issuebank, _cno, _ccexmm, _ccexyy, _cctype, _ccno, _occupation, _painsid, _covertype, _covertypename, _divspousstatus;
            string _cxaccountno, _aucode, _policyno, _orderno;

            _spousename = ""; _spousenric = ""; _spousedob = ""; _spousenationality = ""; _spouseoccupation = ""; _spouserelation = "";
            _cctype = ""; _covertypename = ""; _otherinscom = ""; _nameofcard = ""; _issuebank = ""; _cno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            #endregion

            #region Assign Values
            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _natureofbusi = _dsProposal.Tables[0].Rows[0]["NatBusi"].ToString();
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officephone = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            //_comroc = _dsProposal.Tables[0].Rows[0]["CompanyROCNo"].ToString();
            _painsid = _dsProposal.Tables[0].Rows[0]["PAInsId"].ToString();
            _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
            _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
            int _childcount = Convert.ToInt32(_noofchild);
            string[] _childname = new string[_childcount];
            string[] _childdob = new string[_childcount];
            string[] _childnationality = new string[_childcount];
            string[] _childnric = new string[_childcount];
            string[] _childrelation = new string[_childcount];
            string[] _childgender = new string[_childcount];
            if (_childcount > 0)
            {

                for (int i = 0; i < _childcount; i++)
                {
                    if (_covertype == "INDSPCHD")
                    {
                        _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                        _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                        _childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                        _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                        _childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                        _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                    }
                    else if (_covertype == "INDCHD")
                    {
                        _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                        _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                        _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                        _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                        _childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                        _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                    }
                }
            }


            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _spousename = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                _spousenric = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                _spousedob = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                //_spousenationality = _dsProposal.Tables[1].Rows[0]["SpouseNationality"].ToString();
                _spouseoccupation = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                //_spouserelation = _dsProposal.Tables[1].Rows[0]["SpouseRelation"].ToString();
                _spousegender = _dsProposal.Tables[1].Rows[0]["Gender"].ToString();
                _divspousstatus = "block";
            }
            else
            {
                _divspousstatus = "none";
            }
            if (_covertype == "IND")
            {
                _covertypename = "Individual";
            }
            else if (_covertype == "INDSP")
            {
                _covertypename = "Individual & Spouse";
            }
            else if (_covertype == "INDCHD")
            {
                _covertypename = "Individual & Children";
            }
            else if (_covertype == "INDSPCHD")
            {
                _covertypename = "Individual, Spouse & Children";
            }

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["HasEngagedSportsActivities"].ToString() == "True")
            {
                _engagedsportsstatus = "Yes";
                _enagedsportsreason = _dsProposal.Tables[0].Rows[0]["EngagedSportsActivities"].ToString();
            }
            else
            {
                _engagedsportsstatus = "No";
                _enagedsportsreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalDefects"].ToString() == "True")
            {
                _physicalstatus = "Yes";
                _physicalreason = _dsProposal.Tables[0].Rows[0]["PhysicalDefects"].ToString();
            }
            else
            {
                _physicalstatus = "No";
                _physicalreason = "";
            }


            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceCancelled"].ToString() == "True")
            {
                _inscancel = "Yes";
                _inscancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceCancelledDetails"].ToString();
            }
            else
            {
                _inscancel = "No";
                _inscancelreason = "";
            }


            _cxaccountno = _dsProposal.Tables[0].Rows[0]["CXAccountNo"].ToString();
            _policyno = _dsProposal.Tables[0].Rows[0]["PolicyNumber"].ToString();
            _aucode = _dsProposal.Tables[0].Rows[0]["AuCode"].ToString();
            _orderno = _dsProposal.Tables[0].Rows[0]["OrderNo"].ToString();

            _ccno = "";

            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 30, InsuranceType);
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            #endregion

            _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr>";
            _html += "<tr><td width='25%'><b>Policy Type</b></td><td>" + _covertypename + "</td><td colspan='2' align='right'></td></tr></table>";
            _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                    + "<tr>"
                    + "<td width='50%'>" //Start 1
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Name(as shown in NRIC / Passport)</td>"
                    + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td align='left'>Address</td>"
                    + "<td align='left'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                    + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                    + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                    + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                    + "</table>"
                    + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Occupation</td>"
                    + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Mobile No</td>"
                    + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Email</td>"
                    + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Insurance Start Date</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
                    + "</tr>"

                    + "</table>"
                    + "</td>" //End 1

                    + "<td width='50%'>" //Start 2
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Date of Birth</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Nationality</td>"
                    + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>NRIC Number</td>"
                    + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Gender</td>"
                    + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Nature of Business</td>"
                    + "<td width='50%' align='left'>" + _natureofbusi.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Office No</td>"
                    + "<td width='50%' align='left'>" + _officephone.ToString() + "</td>"
                    + "</tr>"

                    //+ "<tr>"
                    //+ "<td width='50%' align='left'>Company ROC No.</td>"
                    //+ "<td width='50%' align='left'>" + _comroc.ToString() + "</td>"
                    //+ "</tr>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Insurance End Date</td>"
                    + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td>"
                    + "</tr>"

                    + "</table>"
                    + "</td>" //End 2
                    + "</tr>";

            if (_covertype == "INDSP" || _covertype == "INDSPCHD")
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr>"
                + "<td colspan='4' align='left'><b>Spouse Details</b></td>"
                + "</tr>"

                + "<tr><td style='width:25%' align='left'>Spouse Name</td>"
                + "<td style='width: 25%' align='left'>" + _spousename.ToString() + "</td>"
                //+ "<td style='width: 25%' align='left'>Spouse Nationality</td>"
                //+ "<td style='width: 25%' align='left'>" + _spousenationality.ToString() + "</td></tr>"
                + "<td style='width: 25%' align='left'>Spouse NRIC No.</td>"
                + "<td style='width: 25%' align='left'>" + _spousenric.ToString() + "</td></tr>"

                //+ "<tr><td style='width:25%' align='left'>Spouse NRIC No.</td>"
                //+ "<td style='width: 25%' align='left'>" + _spousenric.ToString() + "</td>"
                + "<tr><td style='width:25%' align='left'>Spouse Occupation</td>"
                + "<td style='width: 25%' align='left'>" + _spouseoccupation.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Spouse DOB</td>"
                + "<td style='width: 25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _spousedob.ToString() + "</td></tr>"

                //+ "<tr><td style='width:25%' align='left'>Spouse Relation</td>"
                //+ "<td style='width: 25%' align='left'>" + _spouserelation.ToString() + "</td>"
                //+ "<td style='width: 25%' align='left'>Spouse Occupation</td>"
                //+ "<td style='width: 25%' align='left'>" + _spouseoccupation.ToString() + "</td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>";
            }

            _html += "<tr>"
            + "<td colspan='2'>Number of Children : " + _noofchild.ToString() + "</td>"
            + "</tr>";
            if (_childcount > 0)
            {
                _html += "<tr>"
                + "<td colspan='2'>"
                + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                + "<tr>"
                + "<td colspan='4' align='left'><b>Child Details</b></td>"
                + "</tr>";
                for (int j = 0; j < _childcount; j++)
                {
                    int sno = j + 1;
                    _html += "<tr>"
                    + "<td colspan='4' align='left'><b>Child " + sno.ToString() + "</b></td>"
                    + "</tr>"

                    + "<tr><td style='width:25%' align='left'>Name</td>"
                    + "<td style='width: 25%' align='left'>" + _childname[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Nationality</td>"
                    + "<td style='width: 25%' align='left'>" + _childnationality[j].ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>DOB</td>"
                    + "<td style='width: 25%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _childdob[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>NRICNo</td>"
                    + "<td style='width: 25%' align='left'>" + _childnric[j].ToString() + "</td></tr>"

                    + "<tr><td style='width:25%' align='left'>Gender</td>"
                    + "<td style='width: 25%' align='left'>" + _childgender[j].ToString() + "</td>"
                    + "<td style='width: 25%' align='left'>Relation</td>"
                    + "<td style='width: 25%' align='left'>" + _childrelation[j].ToString() + "</td></tr>";

                }
                _html += "</table>"
                + "</td>"
                + "</tr>";
            }

            _html += "<tr>"
            + "<td colspan='2'>"
            + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

            + "<tr><td colspan='4' align='left'><b>Other Details</b></td></tr>";

            //+ "<tr><td colspan='3' align='left'>(a) Does your occupation fall within any of the Decline of referred Risks?</td>"
            //+ "<td style='width: 25%' align='left'>" + _occupfallstatus.ToString() + "</td></tr>";
            //if (_occupfallstatus.ToString() == "Yes")
            //{
            //    _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
            //    + "<td colspan='3' align='left'>" + _occupfallreason.ToString() + "</td></tr>";
            //}

            _html += "<tr><td colspan='3' align='left'>(1) Do Have you suffered from any physical defect, infirmity or congenital conditions?</td>"
           + "<td style='width: 25%' align='left'>" + _physicalstatus.ToString() + "</td></tr>";
            if (_physicalstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _physicalreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>(2) Do you or the person(s) to be insured engage in any hazardous sports or activities that are likely to cause bodily injury?</td>"
            + "<td style='width: 25%' align='left'>" + _engagedsportsstatus.ToString() + "</td></tr>";
            if (_engagedsportsstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _enagedsportsreason.ToString() + "</td></tr>";
            }
                      

            _html += "<tr><td colspan='3' align='left'>(3) Have you ever had any medical/health or life Insurance application declined, restricted or accepted at other than normal terms?</td>"
            + "<td style='width: 25%' align='left'>" + _inscancel.ToString() + "</td></tr>";
            if (_inscancel.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _inscancelreason.ToString() + "</td></tr>";
            }
          
                _html += " "
                    
                + "<tr><td colspan='4' align='left'></td></tr>"
                + "<tr><td>Account No.</td><td>[" + _cxaccountno + "]</td><td>Policy No.</td><td>[" + _policyno + "]</td></tr>"
                + "<tr><td>Order No.</td><td>[" + _orderno + "]</td><td>AuCode</td><td>[" + _aucode + "]</td></tr>"

                + "</table>"
                + "</td>"
                + "</tr>"

                + "</table>"
                + "</div></div>";

           
          
        }
        return _html;
    }

    //public string GenerateCIHTML_Rsa(Int64 RefId, string InsuranceType)
    //{
    //    DataSet _dsProposal = new DataSet();
    //    ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
    //    _dsProposal = _proposaldownloaddb.GetRSAProposal(RefId, InsuranceType);
    //    string _html = "";
    //    if (_dsProposal.Tables[0].Rows.Count > 0)
    //    {
    //        #region Variable Declaration

    //        string _name, _nric, _nationality, _unitno, _homeno, _address, _postalcode, _mobile, _phoneno, _officeno, _faxno, _expdrivingyr;
    //        string _expdrivingmn, _drivelicenceno, _drivingclass, _yearobtain, _vehicleno, _engineno, _chassisno, _gender, _maritalstatus;
    //        string _hpstatus, _hpcomp, _drwestmylsa, _howopten, _aircon, _radio, _sportsrims, _sunroof, _moonroof, otheraccessories, _vhlemodifystatus;
    //        string _vhlemodifyreason, _hascoe, _carrentalexten, _dealerexten, _sunroofexten, _sunroofamount, moonroofexten, moonroofamount, _otherexten;
    //        string _socialuse, _physicalimpairstatus, _physicalimpairreason, _accidentstatus, _accidentreason, _convictedstatus, _convictedreason;
    //        string _inscancelstatus, _cancelreason, _demeritstatus, _insstatus, _inscomp, _inscomid, _insvhleno, _inspolicyno, _insncd, _insxepdate, _mfgyear;
    //        string _claimstatus, _regyear, _dob, _occupation, _email, _natureofbusiness, _offpeek, _adddriver, _insstartdate, _insenddate, _planname;
    //        string _annualpremium, _ncepercent, _drcount, _isoffdrive, _nextncd, _exxess, _claim1ststat, _claim1stend, _claimcount1, claimamt1;
    //        string _claim2ndstat, _claim2ndend, _claimcount2, claimamt2, _claim3rdstat, _claim3rdend, _claimcount3, claimamt3;
    //        string _drname1, _drdob1, _drocc1, _drage1, _drjobnature1, _drrelation1, _drexpyr1, _drexpmn1, _drclass1, _dryearobtain1, _drgender1, _drmarital1;
    //        string _drname2, _drdob2, _drocc2, _drage2, _drjobnature2, _drrelation2, _drexpyr2, _drexpmn2, _drclass2, _dryearobtain2, _drgender2, _drmarital2;
    //        string _drname3, _drdob3, _drocc3, _drage3, _drjobnature3, _drrelation3, _drexpyr3, _drexpmn3, _drclass3, _dryearobtain3, _drgender3, _drmarital3;
    //        string _drname4, _drdob4, _drocc4, _drage4, _drjobnature4, _drrelation4, _drexpyr4, _drexpmn4, _drclass4, _dryearobtain4, _drgender4, _drmarital4;
    //        string _drname5, _drdob5, _drocc5, _drage5, _drjobnature5, _drrelation5, _drexpyr5, _drexpmn5, _drclass5, _dryearobtain5, _drgender5, _drmarital5;
    //        string _demeritcount, _dmdrname1, _dmdrpoint1, _dmdrdate1, _dmdrtype1, _dmdrname2, _dmdrpoint2, _dmdrdate2, _dmdrtype2, _dmdrname3, _dmdrpoint3;
    //        string _dmdrdate3, _dmdrtype3, _dmdrname4, _dmdrpoint4, _dmdrdate4, _dmdrtype4, _dmdrname5, _dmdrpoint5, _dmdrdate5, _dmdrtype5, _dmdrname6;
    //        string _dmdrpoint6, _dmdrdate6, _dmdrtype6, _cc, _make, _model, _bodytype, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _indd, _inmm, _inyy;
    //        DateTime _isdate, _iedate, _indate;

    //        #endregion

    //        #region Assign Values

    //        _name = ""; _nric, _nationality, _unitno, _homeno, _address, _postalcode, _mobile, _phoneno, _officeno, _faxno, _expdrivingyr

    //        #endregion
    //        _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
    //        _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
    //        _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
    //        _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
    //        _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
    //        _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
    //        _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
    //        _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
    //        _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
    //        _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();

    //        _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
    //        _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

    //        _drwestmylsa = _dsProposal.Tables[0].Rows[0]["DrWMalaysia"].ToString();
    //        _expdrivingyr = _dsProposal.Tables[0].Rows[0]["YearDriveSg"].ToString();
    //        _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
    //        _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
    //        _officeno = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
    //        _empname = _dsProposal.Tables[0].Rows[0]["EmpNameandTrade"].ToString();
    //        if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
    //        {
    //            _claimstatus = "No";
    //        }
    //        else
    //        {
    //            _claimstatus = "Yes";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasPreInsurer"].ToString() == "True")
    //        {
    //            _insstatus = "Yes";
    //            if (_dsProposal.Tables[2].Rows.Count > 0)
    //            {
    //                _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
    //                _insvhleno = _dsProposal.Tables[0].Rows[0]["PreInsVechicleNo"].ToString();
    //                _indate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString());
    //                _indd = _indate.Day.ToString("00");
    //                _inmm = _indate.Month.ToString("00");
    //                _inyy = _indate.Year.ToString();
    //                _inspldate = _dd + "/" + _mm + "/" + _yy;
    //                //_inspldate = _dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString();
    //                if (_dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() == "-1")
    //                {
    //                    _insncdentitle = "";
    //                }
    //                else
    //                {
    //                    _insncdentitle = _dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() + "%";
    //                }
    //            }
    //            else
    //            {
    //                _insstatus = "No";
    //                _inscomp = "";
    //                _insvhleno = "";
    //                _inspldate = "";
    //                _insncdentitle = "";
    //            }
    //        }
    //        else
    //        {
    //            _insstatus = "No";
    //            _inscomp = "";
    //            _insvhleno = "";
    //            _inspldate = "";
    //            _insncdentitle = "";
    //        }

    //        _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
    //        if (_ncdpercent.ToString() == "-1")
    //        {
    //            _ncdpercent = "No NCD(First Policy)";
    //        }
    //        else
    //        {
    //            _ncdpercent += "%";
    //        }
    //        _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
    //        if (_ncdreson == "Others")
    //        {
    //            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
    //        }
    //        else if (_ncdreson == "-1")
    //        {
    //            _ncdreson = "";
    //        }
    //        if (_dsProposal.Tables[1].Rows.Count > 0)
    //        {
    //            _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
    //            _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
    //            claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
    //            _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

    //            _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
    //            _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
    //            claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

    //            _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
    //            _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
    //            claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
    //        }
    //        else
    //        {
    //            _claim1ststat = "";
    //            _claim1stend = "";
    //            claimamt1 = "";
    //            _claimcount1 = "0";

    //            _claim2ndstat = "";
    //            _claim2ndend = "";
    //            claimamt2 = "";

    //            _claim3rdstat = "";
    //            _claim3rdend = "";
    //            claimamt3 = "";
    //            _claimstatus = "No";
    //            _ncdpercent = "0%";
    //        }
    //        _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
    //        if (_ncdpercent.ToString() == "-1")
    //        {
    //            _ncdpercent = "10%";
    //        }
    //        else
    //        {
    //            if (_claimstatus == "No")
    //            {
    //                _ncdpercent = NoNCD(_ncdpercent);
    //            }
    //            else if (_claimstatus == "Yes" && _claimcount1 == "0")
    //            {
    //                _ncdpercent = NoNCD(_ncdpercent);
    //            }
    //            else if (_claimstatus == "Yes" && _claimcount1 == "1")
    //            {
    //                _ncdpercent = OneTimesNCD(_ncdpercent);
    //            }
    //            else
    //            {
    //                _ncdpercent = "0%";
    //            }
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasVechicleModified"].ToString() == "True")
    //        {
    //            _vhlemodifystatus = "Yes";
    //            _vhlemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
    //        }
    //        else
    //        {
    //            _vhlemodifystatus = "No";
    //            _vhlemodifyreason = "";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString() == "True")
    //        {
    //            _inscancelstatus = "Yes";
    //            _cancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceTerminatedReason"].ToString();
    //        }
    //        else
    //        {
    //            _inscancelstatus = "No";
    //            _cancelreason = "";
    //        }

    //        if (_dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString() == "True")
    //        {
    //            _impairstatus = "Yes";
    //            _impairreason = _dsProposal.Tables[0].Rows[0]["PhysicalImpairmentReason"].ToString();
    //        }
    //        else
    //        {
    //            _impairstatus = "No";
    //            _impairreason = "";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasConvictedMoterOffence"].ToString() == "True")
    //        {
    //            _convictedstatus = "Yes";
    //            _convictedreason = _dsProposal.Tables[0].Rows[0]["ConvictedReason"].ToString();
    //        }
    //        else
    //        {
    //            _convictedstatus = "No";
    //            _convictedreason = "";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasAccessory"].ToString() == "True")
    //        {
    //            _accessorystatus = "Yes";
    //            _accessorydetail = _dsProposal.Tables[0].Rows[0]["AccessoryDescription"].ToString();
    //        }
    //        else
    //        {
    //            _accessorystatus = "No";
    //            _accessorydetail = "";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString() == "True")
    //        {
    //            if (_dsProposal.Tables[6].Rows.Count > 0)
    //            {
    //                _demeritstatus = "Yes";
    //                _demeritcount = _dsProposal.Tables[6].Rows.Count.ToString();

    //                _dmdrname1 = _dsProposal.Tables[6].Rows[0]["DriverName"].ToString();
    //                _dmdrpoint1 = _dsProposal.Tables[6].Rows[0]["TotalDemeritPoints"].ToString();
    //                _dmdrdate1 = _dsProposal.Tables[6].Rows[0]["DemeritDate"].ToString();
    //                _dmdrtype1 = _dsProposal.Tables[6].Rows[0]["TypeofOffence"].ToString();
    //                if (_dsProposal.Tables[6].Rows.Count > 1)
    //                {
    //                    _dmdrname2 = _dsProposal.Tables[6].Rows[1]["DriverName"].ToString();
    //                    _dmdrpoint2 = _dsProposal.Tables[6].Rows[1]["TotalDemeritPoints"].ToString();
    //                    _dmdrdate2 = _dsProposal.Tables[6].Rows[1]["DemeritDate"].ToString();
    //                    _dmdrtype2 = _dsProposal.Tables[6].Rows[1]["TypeofOffence"].ToString();
    //                }
    //                if (_dsProposal.Tables[6].Rows.Count > 2)
    //                {
    //                    _dmdrname3 = _dsProposal.Tables[6].Rows[2]["DriverName"].ToString();
    //                    _dmdrpoint3 = _dsProposal.Tables[6].Rows[2]["TotalDemeritPoints"].ToString();
    //                    _dmdrdate3 = _dsProposal.Tables[6].Rows[2]["DemeritDate"].ToString();
    //                    _dmdrtype3 = _dsProposal.Tables[6].Rows[2]["TypeofOffence"].ToString();
    //                }
    //                if (_dsProposal.Tables[6].Rows.Count > 3)
    //                {
    //                    _dmdrname4 = _dsProposal.Tables[6].Rows[3]["DriverName"].ToString();
    //                    _dmdrpoint4 = _dsProposal.Tables[6].Rows[3]["TotalDemeritPoints"].ToString();
    //                    _dmdrdate4 = _dsProposal.Tables[6].Rows[3]["DemeritDate"].ToString();
    //                    _dmdrtype4 = _dsProposal.Tables[6].Rows[3]["TypeofOffence"].ToString();
    //                }
    //                if (_dsProposal.Tables[6].Rows.Count > 4)
    //                {
    //                    _dmdrname5 = _dsProposal.Tables[6].Rows[4]["DriverName"].ToString();
    //                    _dmdrpoint5 = _dsProposal.Tables[6].Rows[4]["TotalDemeritPoints"].ToString();
    //                    _dmdrdate5 = _dsProposal.Tables[6].Rows[4]["DemeritDate"].ToString();
    //                    _dmdrtype5 = _dsProposal.Tables[6].Rows[4]["TypeofOffence"].ToString();
    //                }
    //                if (_dsProposal.Tables[6].Rows.Count > 5)
    //                {
    //                    _dmdrname6 = _dsProposal.Tables[6].Rows[5]["DriverName"].ToString();
    //                    _dmdrpoint6 = _dsProposal.Tables[6].Rows[5]["TotalDemeritPoints"].ToString();
    //                    _dmdrdate6 = _dsProposal.Tables[6].Rows[5]["DemeritDate"].ToString();
    //                    _dmdrtype6 = _dsProposal.Tables[6].Rows[5]["TypeofOffence"].ToString();
    //                }
    //            }
    //            else
    //            {
    //                _demeritstatus = "No";
    //                _demeritcount = "0";
    //            }
    //        }
    //        else
    //        {
    //            _demeritstatus = "No";
    //            _demeritcount = "0";
    //        }

    //        _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
    //        _mfgyear = _dsProposal.Tables[0].Rows[0]["ManufactYear"].ToString();
    //        _regyear = _dsProposal.Tables[0].Rows[0]["DateofReg"].ToString();
    //        _model = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
    //        _make = _dsProposal.Tables[5].Rows[0]["Make"].ToString();
    //        _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
    //        _vehicletype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
    //        _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
    //        _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

    //        _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
    //        _isdd = _isdate.Day.ToString("00");
    //        _ismm = _isdate.Month.ToString("00");
    //        _isyy = _isdate.Year.ToString();
    //        //_insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
    //        _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

    //        _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
    //        _iedd = _iedate.Day.ToString("00");
    //        _iemm = _iedate.Month.ToString("00");
    //        _ieyy = _iedate.Year.ToString();
    //        //_insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
    //        _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

    //        if (_dsProposal.Tables[3].Rows.Count > 0)
    //        {
    //            _hpstatus = "Yes";
    //            _hpcomp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

    //            if (_hpcomp.ToString() == "")
    //            {
    //                _hpcomp = "Not Applicable";
    //            }
    //        }
    //        else
    //        {
    //            _hpstatus = "No";
    //            _hpcomp = "Not Applicable";
    //        }
    //        if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
    //        {
    //            _adddriver = "Yes";
    //            _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
    //        }
    //        else
    //        {
    //            _adddriver = "No";
    //            _drcount = "0";
    //        }
    //        if (_dsProposal.Tables[4].Rows.Count > 0)
    //        {
    //            if (Convert.ToInt16(_drcount) > 0)
    //            {
    //                _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
    //                _drage1 = _dsProposal.Tables[4].Rows[0]["Age"].ToString();
    //                _drgender1 = _dsProposal.Tables[4].Rows[0]["Gender"].ToString();
    //                _drmarital1 = _dsProposal.Tables[4].Rows[0]["Marital"].ToString();
    //                _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
    //                _drexp1 = _dsProposal.Tables[4].Rows[0]["YearOfDrivingInSg"].ToString();
    //            }
    //            if (Convert.ToInt16(_drcount) > 1)
    //            {
    //                _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
    //                _drage2 = _dsProposal.Tables[4].Rows[1]["Age"].ToString();
    //                _drgender2 = _dsProposal.Tables[4].Rows[1]["Gender"].ToString();
    //                _drmarital2 = _dsProposal.Tables[4].Rows[1]["Marital"].ToString();
    //                _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
    //                _drexp2 = _dsProposal.Tables[4].Rows[1]["YearOfDrivingInSg"].ToString();
    //            }
    //            if (Convert.ToInt16(_drcount) > 2)
    //            {
    //                _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
    //                _drage3 = _dsProposal.Tables[4].Rows[2]["Age"].ToString();
    //                _drgender3 = _dsProposal.Tables[4].Rows[2]["Gender"].ToString();
    //                _drmarital3 = _dsProposal.Tables[4].Rows[2]["Marital"].ToString();
    //                _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
    //                _drexp3 = _dsProposal.Tables[4].Rows[2]["YearOfDrivingInSg"].ToString();
    //            }
    //            if (Convert.ToInt16(_drcount) > 3)
    //            {
    //                _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
    //                _drage4 = _dsProposal.Tables[4].Rows[3]["Age"].ToString();
    //                _drgender4 = _dsProposal.Tables[4].Rows[3]["Gender"].ToString();
    //                _drmarital4 = _dsProposal.Tables[4].Rows[3]["Marital"].ToString();
    //                _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
    //                _drexp4 = _dsProposal.Tables[4].Rows[3]["YearOfDrivingInSg"].ToString();
    //            }
    //            if (Convert.ToInt16(_drcount) > 4)
    //            {
    //                _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
    //                _drage5 = _dsProposal.Tables[4].Rows[4]["Age"].ToString();
    //                _drgender5 = _dsProposal.Tables[4].Rows[4]["Gender"].ToString();
    //                _drmarital5 = _dsProposal.Tables[4].Rows[4]["Marital"].ToString();
    //                _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
    //                _drexp5 = _dsProposal.Tables[4].Rows[4]["YearOfDrivingInSg"].ToString();
    //            }
    //        }

    //        DataSet _dsPayment = new DataSet();
    //        _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefId, 29, InsuranceType);
    //        if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
    //        {
    //            _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
    //            _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
    //            _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
    //            _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
    //            _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
    //            _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();

    //            if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
    //                _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
    //            else
    //                _ccno = "";
    //        }

    //        _html = "<table><tr><td width='25%'><b>Plan Name</b></td><td>" + _planname + "</td><td colspan='2' align='right'><b>Annual Premium</b> : $" + _annualpremium.ToString() + "</td></tr></table>";
    //        _html += "<div><div><b>Details of Proposer</b></div><div style='text-align: center'>"
    //                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
    //                 + "<tr>"
    //                 + "<td width='50%'>" //Start 1
    //                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Name</td>"
    //                 + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td align='left'>Address</td>"
    //                 + "<td align='left'>"
    //                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
    //                 + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
    //                 + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
    //                 + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
    //                 + "</table>"
    //                 + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Occupation / Business</td>"
    //                 + "<td width='50%' align='left'>" + _occupation.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Mobile No</td>"
    //                 + "<td width='50%' align='left'>" + _mobile.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Tel. No(O)</td>"
    //                 + "<td width='50%' align='left'>" + _officeno.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "</table>"
    //                 + "</td>" //End 1

    //                 + "<td width='50%'>" //Start 2
    //                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Date of Birth</td>"
    //                 + "<td width='50%' style='mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dob.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Nationality</td>"
    //                 + "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>NRIC Number</td>"
    //                 + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Sex</td>"
    //                 + "<td width='50%' align='left'>" + _gender.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Marital Status</td>"
    //                 + "<td width='50%' align='left'>" + _maritalstatus.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Driving Experience</td>"
    //                 + "<td width='50%' align='left'>" + _expdrivingyr.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td width='50%' align='left'>Employer's Name & Trade</td>"
    //                 + "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
    //                 + "</tr>"

    //                 + "</table>"
    //                 + "</td>" //End 2
    //                 + "</tr>"

    //                 + "<tr>"
    //                 + "<td colspan='2'>"
    //                 + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

    //                + "<tr>"
    //                + "<td colspan='4' align='left'>Claim Experience(Past 3 years) : " + _claimstatus.ToString() + "</td>"
    //                + "</tr>";

    //        if (claimamt1.ToString() == "0")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
    //            + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'> Claim Amount</td>"
    //            + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
    //        }
    //        if (claimamt2.ToString() == "0")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'> Claim Amount</td>"
    //            + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
    //        }
    //        if (claimamt3.ToString() == "0")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'> Claim Amount</td>"
    //            + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td style='width:25%' align='left'>NCD on next renewal (%)</td>"
    //        + "<td colspan='3' align='left'>" + _ncdpercent.ToString() + "</td></tr>";

    //        if (_drwestmylsa != "")
    //        {
    //            _html += "<tr><td colspan='4' align='left'>How often do you drive to West Malaysia : " + _drwestmylsa.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td colspan='4' align='left'><b>Details of Vehicle</b></td></tr>"

    //         + "<tr><td style='width:25%' align='left'>Registration No</td>"
    //         + "<td style='width: 25%' align='left'>" + _vehicleno.ToString() + "</td>"
    //         + "<td style='width: 25%' align='left'>Year of Manufacture</td>"
    //         + "<td style='width: 25%' align='left'>" + _mfgyear.ToString() + "</td></tr>"

    //         + "<tr><td style='width:25%' align='left'>Make/Model</td>"
    //         + "<td style='width: 25%' align='left'>" + _make.ToString() + "/" + _model.ToString() + "</td>"
    //         + "<td style='width: 25%' align='left'>Registration Date</td>"
    //         + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _regyear.ToString() + "</td></tr>"

    //         + "<tr><td style='width:25%' align='left'>Body Type</td>"
    //         + "<td style='width: 25%' align='left'>" + _vehicletype.ToString() + "</td>"
    //         + "<td style='width: 25%' align='left'>CC</td>"
    //         + "<td style='width: 25%' align='left'>" + _cc.ToString() + "</td></tr>"

    //         + "<tr><td style='width:25%' align='left'>Engine No</td>"
    //         + "<td style='width: 25%' align='left'>" + _engineno.ToString() + "</td>"
    //         + "<td style='width: 25%' align='left'>Chassis No</td>"
    //         + "<td style='width: 25%' align='left'>" + _chassisno.ToString() + "</td></tr>"

    //         + "<tr><td style='width:25%' align='left'>Any hire purchase to your motor vehicle?</td>"
    //         + "<td style='width: 25%' align='left'>" + _hpstatus.ToString() + "</td>"
    //         + "<td style='width: 25%' align='left'>Hire Purchase Company</td>"
    //         + "<td style='width: 25%' align='left'>" + _hpcomp.ToString() + "</td></tr>"

    //         + "<tr><td colspan='4' align='left'>Do you have any motor vehicle Insurance? " + _insstatus.ToString() + "</td></tr>";

    //        if (_insstatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Current Insurance Co.</td>"
    //            + "<td style='width: 25%' align='left'>" + _inscomp.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Vehicle No.</td>"
    //            + "<td style='width: 25%' align='left'>" + _insvhleno.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Expiry / Cancellation Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _inspldate.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>NCD (No Claims Discount) entitlement</td>"
    //            + "<td style='width: 25%' align='left'>" + _insncdentitle.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr>"
    //        + "<td colspan='4' align='left'>If NCD is NIL, please provide the reason : " + _ncdreson.ToString() + "</td>"
    //        + "</tr>"

    //        + "<tr><td colspan='4' align='left'>Has the vehicle been modified/converted in anyway from the manufacturer's specifications? " + _vhlemodifystatus.ToString() + "</td></tr>";
    //        if (_vhlemodifystatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Reason</td>"
    //                 + "<td colspan'3' align='left'>" + _vhlemodifyreason.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td colspan='4' align='left'>Are there any additional accessories installed on the vehicle? " + _accessorystatus.ToString() + "</td></tr>";
    //        if (_vhlemodifystatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Accessories Details</td>"
    //                 + "<td colspan'3' align='left'>" + _accessorydetail.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td colspan='4' align='left'>Period of insurance</td></tr>"

    //        + "<tr><td style='width:25%' align='left'>From</td>"
    //        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insstartdate.ToString() + "</td>"
    //        + "<td style='width: 25%' align='left'>To</td>"
    //        + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _insenddate.ToString() + "</td></tr>"

    //        + "<tr><td colspan='4' align='left'><b>Additional drivers : </b>" + _adddriver.ToString() + "</td></tr>";
    //        if (Convert.ToInt16(_drcount) > 0)
    //        {
    //            _html += "<tr><td colspan='4' align='left'>Driver 1</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _drname1.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Age</td>"
    //            + "<td style='width: 25%' align='left'>" + _drage1.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Gender</td>"
    //            + "<td style='width: 25%' align='left'>" + _drgender1.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Marital Status</td>"
    //            + "<td style='width: 25%' align='left'>" + _drmarital1.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Occupation</td>"
    //            + "<td style='width: 25%' align='left'>" + _drocc1.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Driving Experience</td>"
    //            + "<td style='width: 25%' align='left'>" + _drexp1.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_drcount) > 1)
    //        {
    //            _html += "<tr><td colspan='4' align='left'>Driver 2</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _drname2.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Age</td>"
    //            + "<td style='width: 25%' align='left'>" + _drage2.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Gender</td>"
    //            + "<td style='width: 25%' align='left'>" + _drgender2.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Marital Status</td>"
    //            + "<td style='width: 25%' align='left'>" + _drmarital2.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Occupation</td>"
    //            + "<td style='width: 25%' align='left'>" + _drocc2.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Driving Experience</td>"
    //            + "<td style='width: 25%' align='left'>" + _drexp2.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_drcount) > 2)
    //        {
    //            _html += "<tr><td colspan='4' align='left'>Driver 3</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _drname3.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Age</td>"
    //            + "<td style='width: 25%' align='left'>" + _drage3.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Gender</td>"
    //            + "<td style='width: 25%' align='left'>" + _drgender3.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Marital Status</td>"
    //            + "<td style='width: 25%' align='left'>" + _drmarital3.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Occupation</td>"
    //            + "<td style='width: 25%' align='left'>" + _drocc3.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Driving Experience</td>"
    //            + "<td style='width: 25%' align='left'>" + _drexp3.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_drcount) > 3)
    //        {
    //            _html += "<tr><td colspan='4' align='left'>Driver 4</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _drname4.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Age</td>"
    //            + "<td style='width: 25%' align='left'>" + _drage4.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Gender</td>"
    //            + "<td style='width: 25%' align='left'>" + _drgender4.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Marital Status</td>"
    //            + "<td style='width: 25%' align='left'>" + _drmarital4.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Occupation</td>"
    //            + "<td style='width: 25%' align='left'>" + _drocc4.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Driving Experience</td>"
    //            + "<td style='width: 25%' align='left'>" + _drexp4.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_drcount) > 4)
    //        {
    //            _html += "<tr><td colspan='4' align='left'>Driver 5</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _drname5.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Age</td>"
    //            + "<td style='width: 25%' align='left'>" + _drage5.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Gender</td>"
    //            + "<td style='width: 25%' align='left'>" + _drgender5.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Marital Status</td>"
    //            + "<td style='width: 25%' align='left'>" + _drmarital5.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Occupation</td>"
    //            + "<td style='width: 25%' align='left'>" + _drocc5.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Driving Experience</td>"
    //            + "<td style='width: 25%' align='left'>" + _drexp5.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td colspan='4' align='left'><b>Other Information</td></tr>"

    //         + "<tr><td colspan='4' align='left'>Been convicted of any motoring offence (other than parking) in the past 3 years or have prosecutions pending? " + _convictedstatus.ToString() + "</td></tr>";
    //        if (_vhlemodifystatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>Reason</td>"
    //                 + "<td colspan'3' align='left'>" + _convictedreason.ToString() + "</td></tr>";
    //        }

    //        _html += "<tr><td colspan='3' align='left'>Have you or your named driver(s) been given / accumulated demerit points during the last 24 months?</td>"
    //        + "<td style='width: 25%' align='left'>" + _demeritstatus.ToString() + "</td></tr>";
    //        if (Convert.ToInt16(_demeritcount) > 0)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>1. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname1.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint1.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype1.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate1.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_demeritcount) > 1)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>2. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname2.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint2.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype2.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate2.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_demeritcount) > 2)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>3. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname3.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint3.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype3.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate3.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_demeritcount) > 3)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>4. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname4.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint4.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype4.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate4.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_demeritcount) > 4)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname5.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint5.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype5.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate5.ToString() + "</td></tr>";
    //        }
    //        if (Convert.ToInt16(_demeritcount) > 5)
    //        {
    //            _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrname6.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrpoint6.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
    //            + "<td style='width: 25%' align='left'>" + _dmdrtype6.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Date</td>"
    //            + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate6.ToString() + "</td></tr>";
    //        }
    //        _html += "<tr><td colspan='3' align='left'>Has physical impairment which will affect the driving ability?</td>"
    //        + "<td style='width: 25%' align='left'>" + _impairstatus.ToString() + "</td></tr>";
    //        if (_impairstatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
    //            + "<td colspan='3' align='left'>" + _impairreason.ToString() + "</td></tr>";
    //        }
    //        _html += "<tr><td colspan='3' align='left'>Do you have any insurance terminated in the last 12 months due to a breach of any premium payment condition?</td>"
    //                + "<td style='width: 25%' align='left'>" + _inscancelstatus.ToString() + "</td></tr>";
    //        if (_inscancelstatus.ToString() == "Yes")
    //        {
    //            _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
    //            + "<td colspan='3' align='left'>" + _cancelreason.ToString() + "</td></tr>";
    //        }

    //        ProposalDownloadDB _proposaldb = new ProposalDownloadDB();
    //        DataSet dsDownload = new DataSet();
    //        dsDownload = _proposaldb.GetCarDownloadInfo(RefId, Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

    //        string isdownloaded = "False";
    //        if (dsDownload.Tables[0].Rows.Count > 0)
    //        {
    //            isdownloaded = dsDownload.Tables[0].Rows[0]["IsConfirmDownload"].ToString();
    //        }

    //        if (isdownloaded == "False")
    //        {
    //            _html += "<tr><td colspan='4' align='left'><b>Payment Mode : </b>Credit Card</td></tr>"
    //            + "<tr><td style='width:25%' align='left'>Name of the Card</td>"
    //            + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Issuing Bank</td>"
    //            + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Credit Card No.</td>"
    //            + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'>Card expiry date</td>"
    //            + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td></tr>"

    //            + "<tr><td style='width:25%' align='left'>Type of Card</td>"
    //            + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
    //            + "<td style='width: 25%' align='left'></td>"
    //            + "<td style='width: 25%' align='left'></td></tr>"

    //            + "</table>"
    //            + "</td>"
    //            + "</tr>"

    //            + "</table>"
    //            + "</div></div>";
    //        }
    //        else
    //        {
    //            _html += " "

    //            + "</table>"
    //            + "</td>"
    //            + "</tr>"

    //            + "</table>"
    //            + "</div></div>";

    //        }
    //    }
    //    return _html;
    //}

    private string GetTripType(string triptype)
    {
        string TripType = "Single Trip";

        if (triptype == "A")
            TripType = "Annual Multi-Trip";

        return TripType;

    }

    public void ExportGridView(string fileName, Label lblContent, string headerText)
    {
        string attachment = "attachment; filename=" + fileName + ".xls";

        Response.ClearContent();

        Response.AddHeader("content-disposition", attachment);

        Response.ContentType = "application/ms-excel";

        StringWriter sw = new StringWriter();

        HtmlTextWriter htw = new HtmlTextWriter(sw);

        // Create a form to contain the grid

        HtmlForm frm = new HtmlForm();

        frm.InnerHtml = headerText;

        lblContent.Parent.Controls.Add(frm);

        frm.Attributes["runat"] = "server";

        frm.Controls.Add(lblContent);

        frm.RenderControl(htw);

        //GridView1.RenderControl(htw);

        Response.Write(sw.ToString());

        Response.End();

    }

    public string NoNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0")
        {
            _ncd = "10%";
        }
        else if (NCD == "10")
        {
            _ncd = "20%";
        }
        else if (NCD == "20")
        {
            _ncd = "30%";
        }
        else if (NCD == "30")
        {
            _ncd = "40%";
        }
        else if (NCD == "40" || NCD == "50")
        {
            _ncd = "50%";
        }
        return _ncd;
    }

    public string OneTimesNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0" || NCD == "10" || NCD == "20" || NCD == "30")
        {
            _ncd = "0%";
        }
        else if (NCD == "40")
        {
            _ncd = "10%";
        }
        else if (NCD == "50")
        {
            _ncd = "20%";
        }
        return _ncd;
    }

    public void GetCIPDF_Hsbc(Int64 RefId, string InsuranceType)
    {

        HsbcCarMoreDetailDB _hsbccarmoredetaildb = new HsbcCarMoreDetailDB();
        string root = "";
        root = _hsbccarmoredetaildb.GetProposalPDF(RefId, InsuranceType);
        string fileName = "H" + General.GetRefNumber(RefId);
        Response.Clear();
        //root = @"D:\SharedLoc\pdfoutput\hsbc\2010Oct01\H17JH_01-10-2010.pdf";
        if (root != null && root != "")
        {
            try
            {
                FileInfo _fInfo = new FileInfo(root);
                if (_fInfo.Exists)
                {
                    Response.ContentType = "application/pdf";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".pdf\"");
                    Response.TransmitFile(root);
                }
                else
                {
                    Response.ContentType = "text/plain";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=\"FileNotFound.txt\"");
                    Response.Write("File Not found!");
                }
            }
            catch(Exception Ex)
            {
                Response.Clear();
                Response.ContentType = "text/plain";
                Response.AppendHeader("Content-Disposition", "attachment; filename=\"ErrorFound.txt\"");
                Response.Write("File Not found!");
            }
        }
        else
        {
            Response.ContentType = "text/plain";
            Response.AppendHeader("Content-Disposition", "attachment; filename=\"FileNotFound.txt\"");
            Response.Write("File Not found!");
        }
        Response.End();
    }

    private Int32 GetTravelPromoDiscount(string providerid)
    {
        Int32 Discount = 0;
        MyDatabase _db = new MyDatabase();
        string strSql = "SELECT ItemType FROM tblCXPromotion WHERE ProviderCompanyId = '" + providerid + "' and PromotionType = 600 and GETDATE() between StartDate and EndDate";
        DataTable _dt = new DataTable("aTable");
        _dt = _db.GetDataTable(strSql);

        if (_dt != null && _dt.Rows.Count > 0)
        {
            Discount = Convert.ToInt32(_dt.Rows[0]["ItemType"].ToString());
        }

        return Discount;

    }

}
